Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
Javascript to auto-print on open |
Post Reply |
Author | |
Eric24
Team Player Joined: 28 Jun 09 Location: Dallas, TX Status: Offline Points: 29 |
Post Options
Thanks(0)
Posted: 03 Jan 11 at 5:04AM |
I'm having trouble finding the appropriate Javascript to add to the document (via SetOpenActionJavaScript, presumably) to get Acrobat Reader (etc.) to automatically print the document when it's opened. Of course, I realize that it won't actually print the document "silently", but it seems like it should be possible to get it to launch the user's print dialog.
|
|
Ingo
Moderator Group Joined: 29 Oct 05 Status: Offline Points: 3524 |
Post Options
Thanks(0)
|
Hi Eric!
Using the Adobe Reader you can deal a bit with the following two lines. c = Reader with path / Edit1.Text = pdf-document with path: // ShellExecute(hinstance,'open',PChar(c),PChar('/p ' + Edit1.Text),nil,SW_SHOWNORMAL); // ShellExecute(hinstance,'open',PChar(Edit1.Text),PChar('/p /h '),nil,SW_SHOWNORMAL); You can try using keyboard-events, too: // Keybd_Event(VK_MENU,0,0,0); // Keybd_Event(VK_F4,0,0,0); // Keybd_Event(VK_F4,0,KEYEVENTF_KEYUP,0); // Keybd_Event(VK_MENU,0,KEYEVENTF_KEYUP,0); Or try this one: ShellExecute(hinstance,'open',PChar(Edit1.Text),nil,nil,SW_SHOWNORMAL); sleep(2000); Keybd_Event(VK_CONTROL,0,0,0); Keybd_Event(Ord('P'),MapVirtualKey(Ord('P'), 0),0,0); Keybd_Event(Ord('P'),MapVirtualKey(Ord('P'), 0),KEYEVENTF_KEYUP,0); Keybd_Event(VK_CONTROL,0,KEYEVENTF_KEYUP,0); Cheers, Ingo |
|
Eric24
Team Player Joined: 28 Jun 09 Location: Dallas, TX Status: Offline Points: 29 |
Post Options
Thanks(0)
|
Ingo--
Yes, those methods I'm familiar with, but I need to do this with JavaScript, as I don't have control of actually launching the reader. I am generating a PDF file on the server that is delivered to the reader within a browser frame--that works fine, I just want to automatically start the print process (i.e. show the print dialog) as soon as the document has been loaded by the reader-in-browser. That seems possible, in that there is a document JavaScript function to print and a way to add JavaScript to the "onOpen" event, but it's not working for me.
--Eric
|
|
Rowan
Moderator Group Joined: 10 Jan 09 Status: Offline Points: 398 |
Post Options
Thanks(0)
|
Which version of Adobe Reader are you using?
|
|
Eric24
Team Player Joined: 28 Jun 09 Location: Dallas, TX Status: Offline Points: 29 |
Post Options
Thanks(0)
|
Who knows? :) Whatever the end-user has installed. We are testing with 8, 9, and X.
--Eric
|
|
Ingo
Moderator Group Joined: 29 Oct 05 Status: Offline Points: 3524 |
Post Options
Thanks(0)
|
Hi Eric!
...and perhaps it's Foxit. You want a common javascript solution to insert into the pdf for calling the printer dialog. The prob is that each printer dialog from the external pdf-control has slightly different parameters/properties. So you won't get a solution covering all things. QuickPDF has a simple functionality for printing pdf-documents. Perhaps that's the best for you now? Cheers, Ingo |
|
Dimitry
Team Player Joined: 18 Feb 10 Status: Offline Points: 37 |
Post Options
Thanks(0)
|
There is function in Quick PDF Library called SetOpenActionJavaScript().
It embedds a block of JavaScript that is executed as the document is opened.
So it takes just to load PDF file, add some JavaScript and save modyfied PDF.
The most simple JavaScript that prints entire document looks like:
this.print()
In addition here is useful article about Printing page ranges quickly with JavaScript
Edited by Dimitry - 15 Jan 11 at 2:11PM |
|
Regards,
Dmitry |
|
Ruturaaj
Team Player Joined: 12 Aug 09 Status: Offline Points: 29 |
Post Options
Thanks(0)
|
Success of all these methods depends on the Reader Preferences and Security settings, be aware of that please.
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store