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 - range works but full document prints

Regnillif
Registered: Nov 27 2007
Posts: 5

So I am stumped. I am by no means an expert but know enough to be dangerous.
I have this code set for a Button to print pages 25 and 26 of the document, shrink to fit, print just the document with no comments, auto rotate and centre.
 
var pp = this.getPrintParams();
var fv = pp.constants.flagValues;
pp.flags = fv.setPageSize=false;//Sets the Auto-Rotate and Center Flag
pp.interactive = pp.constants.interactionLevel.full;
pp.pageHandling = 2;
pp.printContent = pp.constants.printContents.doc;
pp.firstPage = 26;
pp.lastPage = 27;
this.print(pp);
   
All of that works except that the preview in the print dialogue box shows that all pages will print and indeed that happens. The problem is that the page range of 25-26 is selected. If I change a setting manually at this point then the preview show correctly and things work. So basically all the print options are selected properly when the button is pressed but the whole document prints instead of the page range specified. Any ideas on how to get the print command to print what is selected. Using Acrobat 9.4.5

My Product Information:
Acrobat Pro, Macintosh
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
Strange...your code works for me, but I'm using Acrobat Pro 9.4.1 on Windows XP with a HP 1220C printer.
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Are you aware that the page numbers in JS are zero-based?
So page 25 should be referenced as 24 and 26 should be referenced as 25.
It seems like you're *adding* 1 to the page number instead of *reducing* 1 from it.

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

Regnillif
Registered: Nov 27 2007
Posts: 5
@try67
Sorry, yes I did realize that. I guess I should not have been so detailed about the page numbers. The pages I want are numbered 25 and 26 but are actually physical pages 27 and 28 in the pdf due to the cover and unnumbered contents page.

Mostly was trying to figure out why the print dialogue box was not honoring the selections made by the Javascript button.



@George - The code works for me as in selecting the correct pages etc. The program just prints the whole document even though pages 25 and 26 are shown as selected in the page range.

I did check the pdf in Acrobat 9.4.4 and it had the same error. And on an even older Mac at the office running Acrobat 7 everything works perfectly. So somewhere along the line Acrobat 9 is the problem.
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
It very well could be due to a bug. There have been a number of print-related bugs reported with recent updates. You should report it: https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform
Regnillif
Registered: Nov 27 2007
Posts: 5
Thank you George. It must be a bug since the code works in Acrobat 7. I have just submitted.