Hi All,
M having a html page on which there is a SAVE Button. And when i click on SAVE button , it pop-ups Save Dialog box through which i save the .html as .doc file on local drive.
Now the problem in that is , it saves all data except the images in WORD.
So can any one help me out in how to save .html file with images to .doc file.

Thanks

Nikunj

Dani AI

Generated

As reported, saving a web page as a ".doc" often loses images because the saved file does not include the image binaries. Building on the thread (thanks to and ), here are practical, reliable options that embed images instead of leaving them as external references.

  • Create a single-file web archive (MHTML/.mht). An MHTML file packages HTML plus images in one file; it can be produced by some browsers or server tools and is often openable in Word with images intact.
  • Inline images as data URIs before saving. Programmatically fetch each image, base64-encode it, and replace the src with a data: URI so the HTML becomes self-contained. That single file can then be opened in Word or converted further.
  • Produce a real Word file server-side. Convert the page to a true .docx (or .doc) using a converter (LibreOffice headless, Pandoc, or an OpenXML/commercial library). These converters embed images and give much better fidelity than a renamed HTML file.

Quick troubleshooting notes: background images in CSS are not captured by simply inlining <img> tags; resolve relative URLs to absolute ones before inlining; large embedded images will increase file size dramatically. If the page’s SAVE button only returns raw HTML with a .doc filename, change the server response to return an MHTML or a converted .docx to guarantee images travel with the file.

Recommended Answers

All 2 Replies

well. im guessing it doesn't save the image's because their locations are relative to somewhere else.. if you're using the File>Save As.. in Internet explorer, you have to choose "Web page,complete" rather than "Web page, HTML only". That will copy the images into a folder called {name_of_page}_files, and update all links to point into that folder.

But, I don't know what you mean by save as .doc? You can't just save HTML as a Word Document (well, you can, but it wont be a Word Document). You could then open the saved HTML file in Word, and save it as a DOC file I suppose. Give it a try.

Member Avatar for Member #114696

open the html file with microsoft word. omnce it is opened save it as document file.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.