Copy link to clipboard
Copied
Is there a way to achieve shrinking the appearance of a pdf document using javascript? I am bascially trying to achieve the function available in the Add Header and Footer action (shown below) in javascript instead of the action. I looked in the Adobe Acrobat API reference guide but only see examples related to making pdf fit to page. I am using Windows 10 and Adobe Acrobat Pro.
Copy link to clipboard
Copied
Yes, there is a way to do this. There is no functionality in the Acrobat JavaScript model for directly scaling page content. But there are a couple of techniques. Both button fields and watermarks scale images. The watermark technique is the simplest, but like most complex operations in JS, it has a weirdness.
Create a new page of the desired size. The page dimensions must of course maintain the original aspect ratio. Then use the watermark function to place the source page content over new page. The issue with this technique is that watermarks are also OCG layers. To use this technique to scale all pages in a document will require renaming the OCG layer.
You can read about OCGs and the watermark function here:
http://acrobatusers.com/tutorials/create_use_layers
Copy link to clipboard
Copied
Thank you for your reply. I will look into this. Out of curiousity, is there an action that accomplishes this? I know the "Add Header and Footer" action accomplishes this but the downfall is that it removes any existing header and footer, which I don't want it to do. Thanks in advance.
Sue
Copy link to clipboard
Copied
Any built-in function that might do something useful as a side affect is not reliable for performing that side affect as your main use of the fuction. So no, I don't know of any other Acrobat feature that might scale pages nor would I suggest using one if I did.
Copy link to clipboard
Copied
Scaling can also be achieved using the Preflight tool, which can be triggered using a script. However, it has to be a fixed size. It can't automatically decide what size to scale the pages to based on the white margins of the page, like the Add Header and Footer tool can.
Copy link to clipboard
Copied
Good one, I always forget about preflight. Yeah Callas!!
Copy link to clipboard
Copied
decided to post questions elsewhere.
Copy link to clipboard
Copied
There is a way to shrink documents with a script. In fact there are two ways. However, it's not a single function.
A script can be written to create a new PDF with pages resized in any way.
In both methods, the script first creates a new PDF with blank pages. Then do one of two things.
Method #1 - Place button fields on each page of the new PDF that are the exact size of the desired shrink.
** Load the pages of the source PDF as images into the buttons.
** then flatten the PDF.
Method #2 - Add the pages of the source PDF to the Pages of the new PDF as watermarks.
Copy link to clipboard
Copied
Hello,
I appreciate you sharing these methods. However, I am not allowed to add a page to each document in the batch. I have to maintain the integrity of the page as it is a legal file. Thanks for trying.
Sue