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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
I don't see such an option.