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!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Javascript to auto-print on open
  FAQ FAQ  Forum Search   Register Register  Login Login

Javascript to auto-print on open

 Post Reply Post Reply
Author
Message
Eric24 View Drop Down
Team Player
Team Player
Avatar

Joined: 28 Jun 09
Location: Dallas, TX
Status: Offline
Points: 29
Post Options Post Options   Thanks (0) Thanks(0)   Quote Eric24 Quote  Post ReplyReply Direct Link To This Post Topic: Javascript to auto-print on open
    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.
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 03 Jan 11 at 8:56AM
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


Back to Top
Eric24 View Drop Down
Team Player
Team Player
Avatar

Joined: 28 Jun 09
Location: Dallas, TX
Status: Offline
Points: 29
Post Options Post Options   Thanks (0) Thanks(0)   Quote Eric24 Quote  Post ReplyReply Direct Link To This Post Posted: 03 Jan 11 at 3:51PM
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
Back to Top
Rowan View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 10 Jan 09
Status: Offline
Points: 398
Post Options Post Options   Thanks (0) Thanks(0)   Quote Rowan Quote  Post ReplyReply Direct Link To This Post Posted: 03 Jan 11 at 3:54PM
Which version of Adobe Reader are you using?
Back to Top
Eric24 View Drop Down
Team Player
Team Player
Avatar

Joined: 28 Jun 09
Location: Dallas, TX
Status: Offline
Points: 29
Post Options Post Options   Thanks (0) Thanks(0)   Quote Eric24 Quote  Post ReplyReply Direct Link To This Post Posted: 03 Jan 11 at 10:46PM
Who knows? :) Whatever the end-user has installed. We are testing with 8, 9, and X.
--Eric
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 04 Jan 11 at 7:34AM
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
 
Back to Top
Dimitry View Drop Down
Team Player
Team Player


Joined: 18 Feb 10
Status: Offline
Points: 37
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dimitry Quote  Post ReplyReply Direct Link To This Post Posted: 15 Jan 11 at 11:13AM
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
Back to Top
Ruturaaj View Drop Down
Team Player
Team Player
Avatar

Joined: 12 Aug 09
Status: Offline
Points: 29
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ruturaaj Quote  Post ReplyReply Direct Link To This Post Posted: 15 Jan 11 at 6:43PM
Success of all these methods depends on the Reader Preferences and Security settings, be aware of that please.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store