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 - Auto-Rotate and Center

Shawskins05
Registered: Dec 2 2009
Posts: 4

I am working on a document that has 50+ pages and am wanting to have a print button on most of them to print the exact page. The document is landscape and I need the "Auto-Rotate and Center" toggle to be checked on, but I don't know how to code that. This is what I have so far:

this.print({
bUI: true,
bSilent: false,
bShrinkToFit: false,
nStart: 2,
nEnd: 2
});

Does anyone know how to get the "Auto-Rotate and Center" checked on and where to add it to the code?

Thanks so much for any help.

My Product Information:
Acrobat Pro 8.1.2, Macintosh
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
All of the newer and more complete print parameters require using the PrintParams Object (look it up in the JavaScript Reference, there are examples). But, unfortunately it does not appear that this particular print parameter was included.

The AutoRotate is included for the Nup option. So I thought that maybe this parameter was doing double duty, or that you could do N-Up printing with a 1x1 tile, which should give you the same affect as normal printing.

I tried out both ideas and unfortunately neither panned out. The nUpAutoRotate Option only works when pageHandling is set to Nup and the NUp option does not allow a 1x1 page configuration. It defaults to 2 pages/page

This is a bummer, Such as easy parameter to include.

The value of AutoRotate is always the setting on the last print. So you can set it manually.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

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

kentbaker
Registered: Jun 6 2008
Posts: 5
I remember seeing this post as I was trouble shooting similar. This has worked for me, hope it helps.

var pp = this.getPrintParams();
var fv = pp.constants.flagValues;
pp.flags = fv.setPageSize=false;//Sets the Auto-Rotate and Center Flag
pp.interactive = 0;// 0=interactive, 1=auto, 2=silent
pp.pageHandling = 3;//3=shrink to fit
this.print(pp);

Best,
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Brilliant Kent!! How could I have missed those:( It was the suppress prefix that threw me off.

So how about this code:
var pp = this.getPrintParams();pp.flags &= ~pp.constants.flagValues.suppressCenterpp.flags &= ~pp.constants.flagValues.suppressRotatepp.interactive = 0;// 0=interactive, 1=auto, 2=silentpp.pageHandling = 3;//3=shrink to fitthis.print(pp);

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

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

kentbaker
Registered: Jun 6 2008
Posts: 5
Thank you for demonstrating the proper construction. Much better.
lucaso
Registered: Feb 5 2008
Posts: 49
Just what I was looking for.... works great

although pushing towards senior age, still want to keep up the pace