Clint C. Posted February 10, 2010 Share Posted February 10, 2010 Hi guys and girls I'm trying to generate Word files at runtime with custom values (the usual). The problem that I'm having is inserting the image in my document. I have two ways of accessing my image: Works $imageLocation = "C:\\wamp\\www\\Qualitysheet\\Images\\chart.png"; Doesn't work $imageLocation = ".\\..\\Images\\chart.png"; and I insert my image like this: <img src='$imageLocation' width='$width' height='$height' alt='$imageAltText' /> First case I can move my Word file anywhere, the picture will be shown (as it has a hard coded path). Second case I get the error "Resource Id #4" if I move my Word document to another location (because of the relative path, I understand this). I don't know how to solve this, does anyone have any ideas? Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/191678-insert-image-into-a-word-document/ Share on other sites More sharing options...
freakstyle Posted February 10, 2010 Share Posted February 10, 2010 I haven't created word docs on the fly like this, but have you tried using a url to the image on the server instead of a relative image in there? if that doesn't work your going to have to see how images are saved in the word doc itself and attempt to replicate that functionality. If it's an option, you may be better off creating a pdf then a word doc. Link to comment https://forums.phpfreaks.com/topic/191678-insert-image-into-a-word-document/#findComment-1010396 Share on other sites More sharing options...
Clint C. Posted February 11, 2010 Author Share Posted February 11, 2010 Hi there, thanks for replying. The putting an image on to a server and then linking to that in the word file is something I had thought of. But what if the user loses his internet connection, then he would not see the image? I think I'll have to indeed either dig deeper and see how Word saves an image or go for PDF files. Thanks! Other replies are still welcome. Link to comment https://forums.phpfreaks.com/topic/191678-insert-image-into-a-word-document/#findComment-1010588 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.