Sign in to follow this  
Brainx7

How to download a website as ms word with the pictures inside

Recommended Posts

Brainx7    144

So I have a form in php that has some pics in it. when the user submits, it takes them to a confirmation page which is also php, in this confirmation page I have a button that downloads the page as ms word, when I open the document the pictures are not visible because they are not in the same directory, could there be a way to download everything at the same time or something or idk have the picture be a part of the website without using image src , the code is quite long ,I attached both files so you can see,

Edited by Brainx7

Share this post


Link to post
Share on other sites
Ectara    3097

I have entirely no experience with generating Word documents, so I'm just guessing, but have you tried using a data URI instead of a URL to the file for the images?

Share this post


Link to post
Share on other sites
SimonForsman    7642

You should probably be aware that a html document that you give a .doc extension is still a html document, not a word document and thus it can't include images (it can link to images but those images will have to be downloaded separatly) (Other office suites might also have trouble opening those files as they won't be in the expected format)

 

A far better solution is to actually generate a word document using for example: http://phpword.codeplex.com/ (It is very easy to use)

 

 

If you absolutely insist on using renamed html documents you will have to make an archive (zip for example) containing all the required files (images, stylesheets, etc) or to use data uris (<img src="data::image/png;base64,{base64encodedimagedata}"/>) but i don't know if word supports those. (it might work in newer versions of word (Microsoft added partial support for it in IE8 and made it semi decent in IE9)

Edited by SimonForsman

Share this post


Link to post
Share on other sites
aregee    1072

I worked on something in the past, I think it was called "Microsoft Office SDK" or "Word SDK" or something like that, that I used to generate Word documents on the fly (programmatically).  I tried to find it again for another question here recently with a similar question, but I couldn't find any references to that any more.  Maybe it is included in the "Platform SDK" now, like you do with "Direct X"?  Unless Microsoft has discontinued that SDK, there should exist something to generate Word documents 'on the fly'.

 

Other than that, I remember copying and pasting a whole webpage into Word, would give a good representation of the web page as a word document.

 

Same goes if you are opening HTML documents in Word.  Just remember to save the document as a Word document, and not HTML.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this