Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Use javascript to automate rotating a background image in Adobe Acrobat 2017?

New Here ,
May 17, 2018 May 17, 2018

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);

}

TOPICS
Install update and subscribe to Acrobat
1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
May 17, 2018 May 17, 2018
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 18, 2018 May 18, 2018

How did you add the background image?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 18, 2018 May 18, 2018

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 18, 2018 May 18, 2018

Not possible with a script.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 18, 2018 May 18, 2018

For the landspace pages you can use a rotated image.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 18, 2018 May 18, 2018

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 19, 2018 May 19, 2018
LATEST

Info: With JavaScript you can add Watermarks, not Backgrounds.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 18, 2018 May 18, 2018

JS can't do that. It can only rotate objects like form fields or comments or entire pages.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines