Copy link to clipboard
Copied
I have a file with 5,000 pdfs I'd like to split a single page from each pdf and have it renamed and saved in a new folder.
By a Client ID# and First and Last name.
Copy link to clipboard
Copied
This will require a script. How are the pages renamed?
Copy link to clipboard
Copied
By a Client ID# and First and Last name.
Copy link to clipboard
Copied
The Pdfs are already named by first and last name. We would just add the unique ID to the extracted page.
Copy link to clipboard
Copied
And where does this unique ID come from? Is it in the PDF? or will it be generated?
If generated, how many digits? Is it random or sequential?
To split out the page, use the doc.extractPages() function.
https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/doc.html#extractpages
You have to know the page number and the file path for saving the page as a separate file.
Copy link to clipboard
Copied
I have an excel spreadsheat with the ID's and it's 1-9 numbers.
Copy link to clipboard
Copied
Also I'm not too familiar with JS.
Copy link to clipboard
Copied
It is possible to read a CSV file to get the associated ID file IDs, but you've just gone beyond what can be done through this forum, especially since you are not a programmer. I'd suggest you hire a developer to create this action for you.
Or if you'd like to learn, there's lots of information and samples here for how to accomplish this process.
https://www.pdfscripting.com/public/Form-Data-Handling.cfm
Copy link to clipboard
Copied
I'll manually add the IDs to each name.
If I can just get a code extract the documents. It would be of great help.
I forgot to note that the pdfs contains signatures. Would that be an issue?
This is what I have:
// Open the PDF document
var doc = app.openDoc("C:\Users\NSO\Desktop\Signatures");
// Extract pages
var extractedDoc = doc.extractPages({
nStart: 26, // Starting page number (0-based index)
nEnd: 26, // Ending page number (0-based index)
cPath: "C:\Users\NSO\Desktop\Signatures\New folder" // Path to save the extracted pages
});
// Close the original document
doc.closeDoc();
// Close the extracted document
extractedDoc.closeDoc();
Copy link to clipboard
Copied
The general outline of this code will work when run from the console window or an automation script. But it has several errors and the general outline will not work in an Action.
For an Action script the document object is provided in event.target. There is no need to use the "app.openDoc()" function.
If you read the reference entry for the "extractPages()" function you'll see that it returns NULL when the save path parameter is provided. You cannot have both the file path and get the doc object. And the paths must be complete, i.e., the path must include the file name.
This is how the script should look (note this is an outline and not complete code)
// Build save path, assume it is a subfolder of the path to the current file
var strRoot = event.target.path.replace(/\/[^\/]+$/,"/New Folder/");
// Build save file name. For demo purposes use the current file name
var strFileName = event.target.documentFileName; //
// Save Extracted Page
try{
event.target.extractPages(26,26,strRoot + strFileName);
}catch(e){app.alert("Error extracting page from:" + strFileName + "\n" + e.message);}
Copy link to clipboard
Copied
A signed (not secured) document does not prevent pages from being extracted, but the extracted pages will not be signed, even if the signature field is on one of the extracted pages.