Copy link to clipboard
Copied
Hi all. I have Adobe Acrobat 2017 and I am new to running actions but trying to learn. I have a pdf where the background image is sourced from a file and I need to rotate the image 270 degrees for the landscape pages only. I'd like to use javascript to automate this process. I found code to step through the document and find the landscape pages, but I can't figure out how to reference and rotate the background image. Can someone help?
/* Finds all landscape pages in current document */
var LandscapePageCount = 0;
{
for (PageIndex = 0; PageIndex <= this.numPages - 1; PageIndex++)
{
// check if this page is landscape or portrait
var aRect = this.getPageBox("Media",PageIndex);
var PageWidth = aRect[2] - aRect[0];
var PageHeight = aRect[1] - aRect[3];
if (PageHeight < PageWidth) // Landscape page found
{
LandscapePageCount++;
// NEED HELP HERE
}
}
app.alert("Total number of landscape pages found: " + LandscapePageCount, 3);
}
Copy link to clipboard
Copied
Moving to Installing, Updating, & Subscribing to Acrobat​
Copy link to clipboard
Copied
How did you add the background image?
Copy link to clipboard
Copied
I added it manually (Edit PDF -> Background -> Add, Source = a file on my computer) and I have added it by creating an Action that does the same thing. I add the same footer on every page of the pdf, but the landscape ones need to be rotated 270 degrees and I can't figure out how to change the location of the background image for just those pages.
Copy link to clipboard
Copied
Not possible with a script.
Copy link to clipboard
Copied
For the landspace pages you can use a rotated image.
Copy link to clipboard
Copied
Bernd Alheit, great idea and thank you! But how do I automate the process of selecting the rotated image for landscape pages and the non rotated image for portrait pages?
Copy link to clipboard
Copied
Info: With JavaScript you can add Watermarks, not Backgrounds.
Copy link to clipboard
Copied
JS can't do that. It can only rotate objects like form fields or comments or entire pages.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now