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

Using Javascript to access "Appearance Options" under Add Header

michaelthopkins
Registered: Feb 11 2008
Posts: 13

I am trying to shirk the page of PDFs through use of javascript (which is a smaller part of my overall script). I know that if you select Document --> Header & Footer --> Add and then select "Appearance Options" you can select "Shrink document to avoid overwriting the document's text and graphics". This basically shrinks the document to fit the specified margins.

I want to be able to do all those steps through javascript to the current document opened.

I have attempted to do that through the Batch processing, but it can only do it to a selected file, folder, or all open documents. I want to be able to do this only to the current document my script will be executed on.

Does anyone know if there is code out there to do this? I looked through the Adobe scripting manual and have not found anything on point.

Thanks

Mike

try67
Expert
Registered: Oct 30 2008
Posts: 2398
No. Acrobat JavaScript has no access to that kind of dialogs.
If you want, you can crop all pages using JS, but you will have to manually provide the values to it.

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

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
It is true that there's no direct way to scale a PDF from either the menus and toolbar or the JavaScript DOM. The shrink option on the adding headers and footers dialog is a kind of side feature, not a main feature.

Similary, there are a couple if different indirect ways to scale PDF pages using JavaScript. Probably the best way is to use the doc.addWatermarkFromFile() function.

Here's the technique:
1. Create a new blank PDF with the right number of pages, correctly sized for the new scaling.
2. Save a copy of the original file.
3. Alternately pull pages from the two copies of the original and apply them as watermarks to the new PDF, using the scaling arguments in the doc.addWatermarkFromFile() function.
4. Inbetween the application of a page as a watermark you'll need to rename the OCG that the watermark function creates.

This creates a new scaled PDF. This is an awkward and far from ideal methodology because of the way it changes the PDF internally. You could write a plug-in that performed a much more elegant scaling. But the point is that it works.

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