I created a simple javascript to flatten and scale an annotated document so that I can send it out to another party. The scaling is key as I usually annotate a resized (scaled up) version of the document and then shrink it back down once the annotations are added. Hence, I am using the doc.addWatermarkFromFile() method to scale down the page content and flatten in one fell swoop.
The script works great except that PDF X-Change seems to ignore the nSourcePage parameter when the doc.addWatermarkFromFile() method is called, so it always pulls only the first page from the source file instead of pulling page 2, page 3, and successive pages. This is true even when I put in a number instead of a variable. Is this perhaps a bug in PDF X-Change's implementation of the method, or am I doing something wrong?
Here is the code:
Code: Select all
var currentDoc = this;
for(var i=0;i<currentDoc.numPages;i++){
if(!i){
// Create new document
var flatDoc = app.newDoc();
}else
{
// Add page if document already created
flatDoc.newPage(i);
}
flatDoc.addWatermarkFromFile({
cDIPath: currentDoc.path,
nSourcePage: i,
nStart: i,
nScale: -1
});
}
Thanks,
David