473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to embed image into a word document

Hi, I really need help for this problem.

I must generate a report as a word document and I also have to embed images(images also generated by php) into this word document so customer can download this word document into this own pc and still can see this images.

Generating word document with php is not a problem. But i really get stuck with embedding images into word. I try many ways but they doen't work. And I google internet but cannot find a solution.

Any idea or advices will be appreciated. Thanks in advance.
Nov 27 '06 #1
2 20066
Hi, I really need help for this problem.

I must generate a report as a word document and I also have to embed images(images also generated by php) into this word document so customer can download this word document into this own pc and still can see this images.

Generating word document with php is not a problem. But i really get stuck with embedding images into word. I try many ways but they doen't work. And I google internet but cannot find a solution.

Any idea or advices will be appreciated. Thanks in advance.


This will work.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. //1. Instanciate Word
  3. $word = new COM("word.application") or die("Unable to instantiate Word");
  4. $template_file = "C:/Doc7.doc";
  5. //3. open the template document
  6. $word->Documents->Open($template_file);
  7. $word->Selection->InlineShapes->AddPicture("C://Sunset.jpg", False, True);
  8. //7. save the template as a new document (c:/reminder_new.doc)
  9. $new_file = "c:/Doc7.doc";
  10. $word->Documents[1]->SaveAs($new_file);
  11. //8. free the object
  12. $word->Quit();
  13. $word = null;
  14. ?>
Nov 27 '06 #2
This will work.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. //1. Instanciate Word
  3. $word = new COM("word.application") or die("Unable to instantiate Word");
  4. $template_file = "C:/Doc7.doc";
  5. //3. open the template document
  6. $word->Documents->Open($template_file);
  7. $word->Selection->InlineShapes->AddPicture("C://Sunset.jpg", False, True);
  8. //7. save the template as a new document (c:/reminder_new.doc)
  9. $new_file = "c:/Doc7.doc";
  10. $word->Documents[1]->SaveAs($new_file);
  11. //8. free the object
  12. $word->Quit();
  13. $word = null;
  14. ?>
Thank you very much

_
Nov 27 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Pawel | last post by:
Hello All I tried to embed Excel sheet into HTML page by following command: <iframe src="Tmp.XLS" width="100%" height="500"></iframe> and it works, showing Excel sheet inside the page, but...
0
by: beau | last post by:
Re. Embed or save ms word into OLE field Please help me ! Anybody can help me with a code to embed an ms word file into an access table ? I have ms word templates with bookmarks in my hard...
1
by: snicks | last post by:
I have a series of XLS files which I need to embed into a PowerPoint presentation on an IIS server. I’ll be using VB.NET. I’ve tried using an ASPOSE.PowerPoint control to do this and it does...
5
by: girishmat | last post by:
how to embed or open microsoft word file in a page using php script
13
by: Lloyd Dupont | last post by:
In the good old days I believe people were using the arcane technology which came to be known as COM+ to embed other application's document in their own document. Like a Word with document a...
2
by: manmit.walia | last post by:
Hello Fellow Developers, I have a small problem that you might be able to help me with. The method that I am trying to create is the ability to export a GridView and a image to word or excel. I...
24
by: Manuel | last post by:
Is it possible to embed an image, like a company logo in a CDOSYS generated message? If yes, I´ll apreciate some code sample. I´ve been able to format messages in html the way I like, but I...
1
by: MRe | last post by:
Hi, Is there any way to write a graphical program in CSharp that could be embedded into Word2000. I've read .NET doesn't support creation of ActiveX controls (unless done using C++) but is there...
13
by: windsorben | last post by:
I have some javascript that checks whether or not an answer is correct. It was working fine when the question was asked with text but now that I'm asking the question with audio, the javascript no...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.