I'm having issues with the following javascript, which is meant to add the filename to the last page of the file. While the code listed below works fine as a part of an Acrobat Action (in versions 8-X, minus the jobArrived piece) I get errors referring to undefined member 'numPages'.
I know that javascript will sometimes work even if it isn't correct, and I'm thinking that may be the case here - can anyone help point me in the right direction here?
By the way, I've also tried using this as a .sequ through the Acrobat configurator.
PowerSwitch 10
Acrobat 8
Windows Server 2003
function jobArrived( s : Switch, job : Job )
{
}
({ nStart: this.numPages - 1});
this.addWatermarkFromText({ cText: this.documentFileName.replace(/.pdf$/i,""),
cFont: "Arial",
nFontSize: 9,
nHorizAlign: app.constants.align.right,
nVertAlign: app.constants.align.bottom,
nHorizValue: -30 ,
nVertValue: 20});
Script error - undefined member 'numPages'
Script error - undefined member 'numPages'
Hi Wilson,
you're trying to make use of the JavaScript for Acrobat API within a Switch script package. That doesn't work because Switch has it's own API which is incompatible to the Acrobat one.
What you can do is to use of the Acrobat configurator. There you have access to Acrobat's JavaScript API. However your JavaScript which will work directly in Acrobat have to be modified to work in the Switch context. You find the necessary information within Switch 11 online help under
Introduction->Advanced topics for Designing flows -> JavaScript for applications
Here's an code example code taken from the online help:
// Acrobat is used to make a summary of the annotations resulting in a file that shows you the page
// content and the annotations per page.
// No arguments are required.
if($error == null)
{
try
{
var title = $doc.documentFileName + " summary"
$outfile = $outfolder + '/' + $filename + "_summary.pdf";
$doc.ANsummarize($doc, title, ANSB_Page, null, $outfile, null, false, true, false, false, false, false);
$outfiles.push($outfile);
}
catch(theError)
{
$error = theError;
$doc.closeDoc( {bNoSave : true} );
}
}
$error
Hope that helps.
Regards,
Robert
you're trying to make use of the JavaScript for Acrobat API within a Switch script package. That doesn't work because Switch has it's own API which is incompatible to the Acrobat one.
What you can do is to use of the Acrobat configurator. There you have access to Acrobat's JavaScript API. However your JavaScript which will work directly in Acrobat have to be modified to work in the Switch context. You find the necessary information within Switch 11 online help under
Introduction->Advanced topics for Designing flows -> JavaScript for applications
Here's an code example code taken from the online help:
// Acrobat is used to make a summary of the annotations resulting in a file that shows you the page
// content and the annotations per page.
// No arguments are required.
if($error == null)
{
try
{
var title = $doc.documentFileName + " summary"
$outfile = $outfolder + '/' + $filename + "_summary.pdf";
$doc.ANsummarize($doc, title, ANSB_Page, null, $outfile, null, false, true, false, false, false, false);
$outfiles.push($outfile);
}
catch(theError)
{
$error = theError;
$doc.closeDoc( {bNoSave : true} );
}
}
$error
Hope that helps.
Regards,
Robert