0

I have a HTML page that has a link to a PDF. This PDF opens in a new window. The parent HTML page has a File->Print menu item. When the user clicks Print I want to be able to automatically open the PDF and print it. The printing part is where I am stuck.

Any help would be much appreciated.

Thanks.

1

2 Answers 2

5

If you open that window with a specific name (e.g. target="nameofwin") in the link pointing at the PDF, you might get away with nameofwin.print(). However, I'm not sure if that'd work since the PDF will be shown using a plugin, and not be a native part of the page. There may be some API that allows you to interface with the PDF display plugin, but then you're stuck wondering if you've got Acrobat or FoxIt or WhateverElse running in there.

Sign up to request clarification or add additional context in comments.

Comments

0

You can probably use PDF.js to render the PDF in a hidden div. Then, on your "print" button, register a click in which you add a new print stylesheet to the document, show that div, print the window and then remove the print stylesheet.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.