1 Reply Latest reply on Jun 23, 2015 6:03 AM by try67

    Add page to current pdf file using javascript

    ronakp97773265

      Hi , , ,

      In my current application , I need add blank page to my current pdf file .

      Please advise me .

       

      Notes :I don't need below option

       

      // Open the source documents:

      var source1 = app.openDoc("/C/source1.pdf");

      var source2 = app.openDoc("/C/source2.pdf");

      // Obtain the OCG order array for each source document:

      var mergedOCGArray = new Array();

      var source1OCGArray = source1.getOCGOrder();

      var source2OCGArray = source2.getOCGOrder();

      // Merge the OCG order arrays into the target array:

      for (var i=0; i<source1OCGArray.length; i++)

      mergedOCGArray[i] = source1OCGArray[i];

      var offset = source1OCGArray.length;

      for (var j=0; j<source2OCGArray.length; j++)

      mergedOCGArray[offset + j] = source2OCGArray[j];

      // Create the target document:

      var target = app.newDoc("/C/target.pdf");

      // Insert source1.pdf:

      target.insertPages({

      nPage : -1,

      cPath : "/c/source1.pdf",

      });

      // Insert source2.pdf:

      target.insertPages({

      nPage : target.numPages,

      cPath : "/c/source2.pdf",

      });

      // Set the OCG order array in the target document

      target.setOCGOrder(mergedOCGArray);

      // Save the target document:

      target.saveAs({

      "/c/target.pdf");

      });

      // Close the target document without notifying the user:

      target.closeDoc(true);

       

      Thanks in advance ,

       

      ROnak Patel