Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save HTML Page as Word or PDF file

Status
Not open for further replies.

Phil99

Programmer
Jul 12, 2002
32
0
0
GB
Hi

From my site i'm displaying a html report to the user. Is it possible to save the html report as for example a word document or a pdf file?

At the moment i can only save the page as a htm file using <a href="javascript:doSaveAs()">save this page</a> which isn't ideal.

Many Thanks

Phil
 
dont think so, however you might want to try this workaround for word.

enclose your entire page (the part that u want to print) in a div tag called "DivToPrint"

create an iframe. in your saveAs code:

function saveAs()
{
theIfrm = parent.frames["IFRMNAME"]
theIfrm.document.open();
theIfrm.document.write("<html>");
theIfrm.document.write("<content type='WORD'>");
theIfrm.document.write(document.getElementById("DivToPrint").innerHTML);
theIfrm.document.write("</html>");
theIfrm.document.close();

}

<content type='WORD'>
is the most important tag. what i have given is incomplete / wrong tag, you have to do some research and pick the correct mime type for word.

try it out...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top