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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to print 8-page PDF from browser

Status
Not open for further replies.

CHDesign

Programmer
Oct 12, 2008
1
US
Hi,

I am trying to print an 8-page PDF using the following javascript:

<script>
function makepage(src)
{
// We break the closing script tag in half to prevent
// the HTML parser from seeing it as a part of
// the *main* page.

return "<html>\n" +
"<head>\n" +
"<title>Vicki's Full Restaurant Menu</title>\n" +
"<script>\n" +
"function step1() {\n" +
" setTimeout('step2()', 10);\n" +
"}\n" +
"function step2() {\n" +
" window.print();\n" +
" window.close();\n" +
"}\n" +
"</scr" + "ipt>\n" +
"</head>\n" +
"<body onLoad='step1()'>\n" +
"<embed src='" + 'VickisMenu70percent.pdf' + "'/>\n" +
"</body>\n" +
"</html>\n";
}

function printme(evt)
{
if (!evt) {
// Old IE
evt = window.event;
}
var image = evt.target;
if (!image) {
// Old IE
image = window.event.srcElement;
}
src = image.src;
link = "about:blank";
var pw = window.open(link, "_new");
pw.document.open();
pw.document.write(makepage(src));
pw.document.close();
}
</script>

This has worked well for me in the past when printing a JPEG. Currently I got it to work, but it only prints the first page of the PDF.

I must admit I am not much of a programmer and have copied this code and am trying to modify it for my current purpose.

Any help is appreciated.

Regards.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top