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

1. Adding a new page in Javascript gives "page are out of range" message 2. running preflight in Js

Community Beginner ,
Sep 19, 2022 Sep 19, 2022

Copy link to clipboard

Copied

Issue 1

I want to add some new pages to my existing document using Javascript. Here is my code:

addNewPage = [
  [30, 687.8389587],
  [28, 78.81201171875],
  [24, 156.84698486328125],
  [20, 10.190933227539062],
  [16, 60.06394958496094],
  [11, 2.958984375],
  [7, 70.81497192382812],
  [3, 278.82696533203125]
]

for (var p = 0; p < addNewPage.length; p++) { 
  var newPageAfter = addNewPage[p][0]
  var newPageHeight = addNewPage[p][1]
  var newPageWidth = 595;
 // this.newPage(newPageAfter, newPageWidth, newPageHeight);
  console.println("newPageAfter = " + newPageAfter + " newPageWidth = " + newPageWidth + " newPageHeight = " + newPageHeight);
}

 This code adds pages successfully. But gives this message:

"Dimensions of this page are out of range. Page content might be truncated."

Then I tried it one by one like the following:

this.newPage(30,595,687.8389587);
this.newPage(28,595,78.81201171875);

All these lines ran successfully without any message.

And I found out that it throws the message at this line:

this.newPage(11,595,2.958984375);

More interestingly, if I run this line multiple times, it only throws the message only at the first instance:

this.newPage(11,595,2.958984375); //throws message
this.newPage(11,595,2.958984375); //no message
this.newPage(11,595,2.958984375); //no message

If I change the height to any other number (2,3,...) it also works without any message. I thought this has something to do with this particular number 2.958984375. But no, I have ran this line in other pdfs without any message.

Can anyone explain this? How can I avoid getting this message?

Is it something to do with my file? I am attaching the file here.

 

Issue 2

I tried running a preflight profile in Javascript. This profile ran successfully from the Preflight menu removing page objects outside trim area but did nothing when I used this code in Javascript.

var oProfile = Preflight.getProfileByName("1_Remove page objects outside trim area")
    if (oProfile != undefined) {
        var oThermometer = app.thermometer;
        var myPreflightResult = this.preflight(oProfile, false, oThermometer); 
        if (myPreflightResult.numErrors > 0) {
		console.println("Preflight found " + myPreflightResult.numErrors + " Errors.")};
        } else {
            console.println("Preflight found no Errors.");
        }

Is something wrong with the code or it is impossible using Javascript?

I am using Adobe Acrobat Pro DC.

TOPICS
Edit and convert PDFs , JavaScript

Views

897

Translate

Translate

Report

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 ,
Sep 19, 2022 Sep 19, 2022

Copy link to clipboard

Copied

1. Code worked fine for me (I enabled the newPage command, of course...). See attached.

2. You'll need to share your profile for further help with this.

Votes

Translate

Translate

Report

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 Beginner ,
Feb 07, 2023 Feb 07, 2023

Copy link to clipboard

Copied

I am sorry. I was my fault- "1_Remove page objects outside trim area" was not a profile, it was a fixup. I had to create a preflight profile with the fixup. And now it worked. 

When I run the profile now, it does all the fixups and saves the existing file. Is there any way to run the profile without saving the file or saving as another file?

Votes

Translate

Translate

Report

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 ,
Feb 08, 2023 Feb 08, 2023

Copy link to clipboard

Copied

LATEST

I don't see such an option.

Votes

Translate

Translate

Report

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