Jump to content

Need javascript to open print dialog box in PDF


simcoweb

Recommended Posts

We are using a PDF generator plugin for Wordpress that creates the PDF for the page being viewed. We'd also like to add the option for the visitor to generate AND print the PDF (option #1 just to generate and download, option #2 to generate and print). However, when they choose the 'print' option we want the PDF file to generate, open in a new tab/window, and immediately display the printer dialog box so all they have to do is hit the Print button.

 

I've seen this done before and, from what i've found on how to do it, it requires embedding the javascript code into the PDF file which then, when being opened by the browser, acts on the command to open the printer dialog box.

 

Anyone have a solution for this? Thanks in advance!

Link to comment
Share on other sites

Thanks for  your post. I had already found that link through another source. The problem is it's using a completely different library/class to generate the PDF files ( the fpdf.php ). I emailed the that author but did not hear back. I was hoping he would explain what part of the code was necessary element in opening the print dialog box and how it could be adapted to our use.

 

The first code box shows that it 'requires' the fpdf.php file to work and states it's an extension of that file. Then the next code box shows an example of how to do exactly what we want, open the dialog box, but there's nothing about how this code actually gets INTO the PDF file.

 

What I really need, regarding that script, is how it can be used with other scripts other than the fpdf.php. As mentioned, we're already using a Wordpress plugin that generates the PDF files just fine. All we want is to have it open with the print dialog box.

 

Do you have any ideas on how the code from that link would be adapted into our use?

Link to comment
Share on other sites

You should review the Acrobat JavaScript Scripting Reference at http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/javascript/AcroJS.pdf

 

In Page 507, you'll find the following example,

// get the printParams object of the default printer
var pp = this.getPrintParams();
// set some properties
pp.interactive = pp.constants.interactionLevel.automatic;
pp.colorOverride = pp.colorOverrides.mono;
// print
this.print(pp);

 

 

You would need to review the document for details though.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.