Page 1 of 1

.insertPages by Acrobat

Posted: Sun Apr 21, 2013 6:25 pm
by nicktazo
Dears



i am trying to use below script to insert newPage in opened PDF but failure



$doc.insertPages({nPage:$doc.numPages-1, cPath:"blank.pdf"});



the Error will be prompted by app as



"RaiseError:file problem"



Could you kindly help me to get one solution or a sample of inserting.



Thanks much



Nick



.insertPages by Acrobat

Posted: Wed Sep 17, 2014 5:43 pm
by pcobee
Here are two scripts for inserting blank pages into a PDF. It does not require the use of a "blank" PDF. The first inserts a single page at the indicated insertion point. The second inserts a page before or after EVERY page in the PDF based on the value of Argument 1.



/*==============================================================

// This script can be used to add a single blank page to a PDF:

* $arg1 = Page Insertion point

0 will put before page 1

> 0 will inserts after page number passed in Arg1

----------------------------------------------------------------

Author: Paul O'Brien, AccuLink

==============================================================

*/



if($error == null)

{

try

{

var Rect = $doc.getPageBox("Crop");

$doc.newPage($arg1, Rect[2], Rect[1]);

}

catch(theError)

{

$error = theError;

$doc.closeDoc( {bNoSave : true} );

}

}







/*====================================================================

// This script can be used to add a blank page before/after EVERY page

* $arg1 = Page Insertion point

0 will start first blank page at front of PDF

1 will start first blank page after first page

----------------------------------------------------------------

Author: Paul O'Brien, AccuLink

====================================================================

*/



if($error == null)

{

try

{

var Rect = $doc.getPageBox("Crop");

if ( $arg1 == 0 ) {

for ( var pagePos=0; pagePos<$doc.numPages; pagePos+=2 ) {

$doc.newPage(pagePos, Rect[2], Rect[1]);

}

}

else {

for ( var pagePos=1; pagePos<=$doc.numPages; pagePos+=2 ) {

$doc.newPage(pagePos, Rect[2], Rect[1]);

}

}

}

catch(theError)

{

$error = theError;

$doc.closeDoc( {bNoSave : true} );

}

}

.insertPages by Acrobat

Posted: Wed Sep 17, 2014 6:03 pm
by gabrielp
pcobee wrote: Here are two scripts for inserting blank pages into a PDF.
Thanks for sharing, man!