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
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:
...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
Copy link to clipboard
Copied
Thanks so much!