Skip to main content
Participant
Jan 20, 2020 9:56 PM UTC
Question

How can I make a single new .PDF out of many .PDF's 1st pages with javascript?

Good Forum Folk,

 

  I wish to create a new .PDF composed of all the first pages of a large number of other .PDF's.  My preferred approach would be to create an Action with the "Default option:" of "Add folder..." as its first step.  At present I have the following javascript as my second step:

 

this.print(false,0,0,true);  [which sends p. 1 of the selected .PDF as a print job to the last-used printer]
this.closeDoc(true);        [which closes the selected document]

 

I would like to improve the script so that it only prompts to begin the process once (instead of for each .PDF included in the batch).

 

I look forward to your suggestions.

 

QD

This topic is closed to new replies. Start a new post to keep the conversation going.

2 replies

Thom Parker
Community Expert
Community Expert
Jan 20, 2020 11:06 PM UTC

One strategy is to create a PDF from first page of the first document processed, using the "doc.extractPages" function. Do not close this doc or extract it with a path. Instead, place the document object returned from extract pages into a global variable. Then for every document after that insert a page into the document. 

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
try67
Community Expert
Community Expert
Jan 20, 2020 10:39 PM UTC

You can use the extractPages command to export the first pages to a single folder, and then manually combine all the files in that folder.

You do not need to add a closeDoc command to an Action. It does that automatically.

Translate