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

JavaScript Print Button and Page Labels like '2-3'

dirkk11
Registered: Nov 24 2011
Posts: 3

Hello,
 
i have searched the web and haven't found a solution for the following problem. I have also postes it on the official Acrobat Scripting Forum, but no one has a solution.
 
My Problem is simple: I want one or more buttons on a Page in my PDF File which prints the last three sites (the last page is the one with the button). And it should also be able to enable some print options like 2 pages on 1, duplexmode and grayscale. So my first solution was the following:
 
> this.print(true, this.pageNum -3, this.pageNum);
 
But it doesn't work, because in the print dialog (which is required to set the print options) the page range is set to, for example "2-3 - 2-5" and i alwas got an "invalid page range" error if i want to continue.
 
So my next idea was to call the print function silently and set the print options by calling "Print options" from the menu:
 
> app.execMenuItem("PageSetup")
> this.print(false, this.pageNum -3, this.pageNum);
 
It does work, but if i set the printer settings in the PageSetup Dialog, it doesn't apply to the following print command. I can set what i want in the PageSetup Dialog- the print() function will always ignore it.
 
Next idea was to extract the pages or temporarely rename the pages. Both isn't possible/ now allowed because the document is protected.
 
My last idea was to ask the user manually for duplex mode, 2 on 1 and grayscale and set it to the print params:
 
> var pp = this.getPrintParams();
> pp.colorOverride = pp.constants.colorOverrides.gray;
> pp.firstPage = this.pageNum;
> pp.lastPage = this.pageNum +3;
> pp.pageHandling = pp.constants.handling.nUp;
> pp.nUpPageOrders = pp.constants.nUpPageOrders.Vertical;
> pp.nUpNumPagesV = 2;
> pp.nUpNumPagesH = 1;
> pp.nUpAutoRotate = true;
> pp.nUpPageBorder=true;
> pp.DuplexType = 1;
> pp.interactive = pp.constants.interactionLevel.silent;
> this.print(pp);
 
I have removed the user prompts app.alert() and set alle the settings a user can made. But only the "2 on 1" feature works, both duplex and grayscale doesn't work. Also this solution is a bit unflexible.
 
Does anyone has an idea, how to solve these problems?
 
Thank you in advance,
Dirk K.

My Product Information:
Acrobat Pro 9.4, Windows
dirkk11
Registered: Nov 24 2011
Posts: 3
Push, no one has a idea?
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Any reason you're not using the constants (like pp.constants.duplexTypes.DuplexFlipShortEdge) to set the DuplexType?

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
In many versions of Acrobat, you need a special application folder to print silently. See the Acrobat JS API Referenced for more information. Version X requires as special privileged folder.

George Kaiser

dirkk11
Registered: Nov 24 2011
Posts: 3
Thanks try67 and George Kaiser for answering.

I didn't know that there is a constant 'pp.constants.duplexTypes.DuplexFlipShortEdge', i didn't found it in the 'Javascript for Acrobat API'. But it works, that's great! The only thing that doesn't work now is printing in gray color mode.

> In many versions of Acrobat, you need a special application folder to print silentlySilently printing works if the page labels are not in format '3-4', can a special folder help to fix the problem?