These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

set print range without dialog

StephenDickason
Registered: Jun 28 2007
Posts: 7

Is it possible in JavaScript to set the print range without bringing up the print dialog, especially from a bookmark entry.

My Product Information:
Reader 7.0.0, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Yes and No. There is a JavaScript print function that takes a huge range of parameters, including page range. However, when executed from a document script it always displays the print dialog. This is a security thing. The good bit is that the print dialog will reflect the parameters you set in the script.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

StephenDickason
Registered: Jun 28 2007
Posts: 7
Storing a bundle of related documents possibly more than 1 page each (but generally 1 page) in 1 PDF, wanting to auto-select the correct page range for the user when printing a multipage document - ie page subrange.

I expect either need button on each page or a global print/select option(or variable) on the bookmark tree to determine what clicking a bookmark will do.

Is there an easy way to show the global print/select state? Or maybe add a command to the right click menu on the bookmarks?

Alternatively, need to keep the button from printing and only showing on the screen, but this seems the messier option.
efos
Registered: Jan 8 2009
Posts: 63
Quote:
Yes and No. There is a JavaScript print function that takes a huge range of parameters, including page range. However, when executed from a document script it always displays the print dialog. This is a security thing. The good bit is that the print dialog will reflect the parameters you set in the script.
True, but let me clarify what he's saying to you.

The code this.print({bUI: false, nStart: startPage, nEnd: endPage, bSilent: false});
Will print the specified range (startPage-endPage) without the print settings dialog. bSilent set to true will suppress the cancel print dialog; I wouldn't recommend it on a silent print in a large doc. That much is possible.

What Thom is referring to is a [i]security[/i] dialog, warning you that it is about to print. Accepting this box will then print silently (or not) as you instructed via print().

Additionally, this nag will only pop up once as far as I have seen; and the decision will be remembered. Good and bad. If you said yes, any further print calls will execute. If you said no, you will have to reopen the document to print anything by this method. This may or may not be a problem for you, but there you have it.

Quote:
I am using the following line to populate the Print dialog box.
xfa.host.print(1, "0", (xfa.host.numPages-1).toString(), 0, 1, 0, 0, 0)
I can refer you to the PrintParams documentation in the JS API reference; while powerful I'm not sure if it can do exactly what you need. Worth a look if you haven't.
efos
Registered: Jan 8 2009
Posts: 63
It's the first link in the (sticky) FAQ thread at the top of this forum. Good luck
grouch
Registered: Mar 27 2009
Posts: 1
Hi
I've used a range of variations of - this.print({bUI: true, nStart: startPage, nEnd: endPage, bSilent: false}); - as a button action to allow users to print just a section of the document. It works perfectly in Reader and AcroPro 8 and 9 on PC and in AcroPro 8 on OSX. However, in Reader on OSX, although the dialogue shows the range has been selected to print, the entire document is previewed and prints (111 pages!). If you change the range in any way, say, by adding a space at the end, it sets it properly, even if you then delete the space. Is this a bug or am I missing something?