• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Creating separate pages pdf using (exportAsSinglePages, singlePagesPDFSuffix).

Explorer ,
Mar 18, 2022 Mar 18, 2022

Copy link to clipboard

Copied

How to create single pages pdf for the selected range using script. Unable to find a solution through the forum except looping through pages.

 

TOPICS
Scripting

Views

244

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 18, 2022 Mar 18, 2022

Hi @Singaaram , there are the exportAsSinglePages and  singlePagesPDFSuffix properties in pdfExportPreferences. This exports pages 2 and 4 to a chosen folder using the PDF/X-4 preset

 

 

var f = Folder.selectDialog("Select a folder for the PDF pages"); 
var doc = app.documents.item(0);
var n = doc.name.replace(/\.[^\.]+$/, '')
var thePath = f + "/" +  n + ".pdf";
var preset=app.pdfExportPresets.itemByName("[PDF/X-4:2008]");


//the exportAsSinglePages property set to true exports single pages. T
...

Votes

Translate

Translate
Community Expert ,
Mar 18, 2022 Mar 18, 2022

Copy link to clipboard

Copied

Presumably, you are aware of the "Create Separate PDF Files" facility in the Export Adobe PDF dialogue box?

 

separate PDFs.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 18, 2022 Mar 18, 2022

Copy link to clipboard

Copied

Hi Derek,

 

Thanks. Yes I am aware of that. But in a scripting I don't know how to integrate this in pdf creation.

I have this code only. But this did not worked for ranges. So I had to make alternate solution. 

myPages = theDoc.pages;
for (i = 0; i < myPages.length; i += 1) {
myPage = myPages[i];
myPageName = padder(i + 1, 2);
myPageRange = myPage.name;
myFilePath = myFolder + "/" + docNameNoExt + "_Big_" + myPageName + ".pdf";
myPerPageFile = new File(myFilePath);
app.pdfExportPreferences.pageRange = myPageRange;
theDoc.exportFile(ExportFormat.pdfType, myPerPageFile, false, myPDFExportPreset);
}
function padder(n, width, leadingSymbol) {
leadingSymbol = leadingSymbol || "0";
n = n + "";
return n.length >= width ? n : new Array((width - n.length) + 1).join(leadingSymbol) + n;
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 18, 2022 Mar 18, 2022

Copy link to clipboard

Copied

Hi @Singaaram , there are the exportAsSinglePages and  singlePagesPDFSuffix properties in pdfExportPreferences. This exports pages 2 and 4 to a chosen folder using the PDF/X-4 preset

 

 

var f = Folder.selectDialog("Select a folder for the PDF pages"); 
var doc = app.documents.item(0);
var n = doc.name.replace(/\.[^\.]+$/, '')
var thePath = f + "/" +  n + ".pdf";
var preset=app.pdfExportPresets.itemByName("[PDF/X-4:2008]");


//the exportAsSinglePages property set to true exports single pages. The singlePagesSuffix set to _the page number
app.pdfExportPreferences.properties = {pageRange:"2,4", exportAsSinglePages:true, singlePagesPDFSuffix:"_^P"}
doc.exportFile(ExportFormat.pdfType, File(thePath));

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 18, 2022 Mar 18, 2022

Copy link to clipboard

Copied

LATEST

Hi @rob day, Thank you so much.

That works perfectly.🤟🏼🤩 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines