.insertPages by Acrobat

Post Reply
nicktazo
Newbie
Posts: 13
Joined: Sat Apr 13, 2013 5:31 pm

.insertPages by Acrobat

Post 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


pcobee
Member
Posts: 21
Joined: Fri Apr 01, 2011 5:06 pm
Location: Greenville NC
Contact:

.insertPages by Acrobat

Post 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} );

}

}
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

.insertPages by Acrobat

Post by gabrielp »

pcobee wrote: Here are two scripts for inserting blank pages into a PDF.
Thanks for sharing, man!
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
Post Reply