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

Trouble with permanent crop code

Guest
Nov 24, 2020 Nov 24, 2020

Copy link to clipboard

Copied

Hi. I have a script that is meant to crop a pdf permanently by setting the media box to the crop box.

However when I run it I get the following error:

for(var i=0;i<this.numPages;i++)
var rCrop= this.getPageBox("Crop",i)
this.setPageBoxes("Media",i,i,rCrop)

TypeError: Invalid argument type.
Doc.setPageBoxes:1:Console undefined:Exec
===> Parameter nStart.

 

any help would be much appreciated.

Thanks

TOPICS
Acrobat SDK and JavaScript

Views

328

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

correct answers 1 Correct answer

Community Expert , Nov 24, 2020 Nov 24, 2020

Notice that the line number of the error is "1".  Are you executing this code one line at a time?  They need to be run all at the same time, but the "for" block also needs to be enclosed in brackets, and all the statements in the block need to end in a semicolon. Like this

 

for(var i=0;i<this.numPages;i++)
{
   var rCrop= this.getPageBox("Crop",i);
    this.setPageBoxes("Media",i,i,rCrop);
}

 

 

You'll find a tutorial on using the Console for exactly this sort of thing here:

https://www.pdfscripting.com/public/Free_Videos.cfm#JSIntro

...

Votes

Translate

Translate
Community Expert ,
Nov 24, 2020 Nov 24, 2020

Copy link to clipboard

Copied

Notice that the line number of the error is "1".  Are you executing this code one line at a time?  They need to be run all at the same time, but the "for" block also needs to be enclosed in brackets, and all the statements in the block need to end in a semicolon. Like this

 

for(var i=0;i<this.numPages;i++)
{
   var rCrop= this.getPageBox("Crop",i);
    this.setPageBoxes("Media",i,i,rCrop);
}

 

 

You'll find a tutorial on using the Console for exactly this sort of thing here:

https://www.pdfscripting.com/public/Free_Videos.cfm#JSIntro

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
Guest
Nov 24, 2020 Nov 24, 2020

Copy link to clipboard

Copied

LATEST

Thanks so much!

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