Skip to main content
Correct answer try67

Creating a text file is tricky, but you can easily output this information to the JS Console and then copy it from there.

The code to do that is this:

console.println(this.documentFileName + " = " + this.numPages + " pages");

Then run this code as a part of an Action on your files, open the JS Console (Ctrl+J) when the Action is finished, and copy its contents to a text file.

3 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
June 7, 2024

Creating a text file is tricky, but you can easily output this information to the JS Console and then copy it from there.

The code to do that is this:

console.println(this.documentFileName + " = " + this.numPages + " pages");

Then run this code as a part of an Action on your files, open the JS Console (Ctrl+J) when the Action is finished, and copy its contents to a text file.

JR Boulay
Community Expert
Community Expert
June 7, 2024

1- Create a Preflight Profile Check (Print Production Tools : Preflight : Options : New Profile).

2- Use this Preflight Check in a Action (Action Wizard : New Action).

You can get a PDF, XML or TXT report.

 

 

 

 

Acrobate du PDF, InDesigner et Photoshopographe
Ella5EECAuthor
Participating Frequently
June 8, 2024

Looks so simple and clean, yet the actual txt is not made. At the end of the action I get a report file and it sais that the txt is made, but the folder is empty 😞

JR Boulay
Community Expert
Community Expert
June 8, 2024

Yes, it's a bug that hasn't been fixed since February (contrary to what the development team had promised me).
I had to insist a lot and several times for them to provide me with a link to reinstall a 2023 version of Acrobat, so I think I'm going to have to wait a long time before triggering an update.

😞

Acrobate du PDF, InDesigner et Photoshopographe
PDF Automation Station
Community Expert
Community Expert
June 7, 2024

Create an Action that executes a JavaScript.  The script will create a global variable that accumulates the document file names and corresponding number of pages with separators.  Create another script that creates a PDF, and then a data object text file (attachment) using the global variable string, replacing the separators with carriage returns, then deletes the global variable so it is "undefined" for the next Action run.

Ella5EECAuthor
Participating Frequently
June 8, 2024

Thank you! The actual script lines would be of great help!

PDF Automation Station
Community Expert
Community Expert
June 8, 2024

Here's the action:

 

 

if(global.page_Count==undefined)
{
var pg="pages";
if(this.numPages==1){pg="page"}
global.page_Count=this.documentFileName.replace(".pdf", "") + "=" + this.numPages + " " + pg+"--";
}
else
{
var pg="pages";
if(this.numPages==1){pg="page"}
global.page_Count+=this.documentFileName.replace(".pdf", "") + "=" + this.numPages + " " + pg+"--";

}

 

 

After the action runs you can test the result in the console by running this script:

global.page_Count

The result should be:

Filename 1 = 5 pages--Filename 2 = 24 pages--Filename 3 = 1 page-- (etc.)

If you run the following script in the console you can copy and paste the result into a text file:

 

global.page_Count.replace(/--/g,"\r");

When you are finished make sure you run the following script in the console:

 

delete global.page_Count;

The script above will ensure that if run the action again in the same session it does not add to the existing list.  If you still want to create the text list you can run the following script in the console, or create a custom menu item or toolbar button (the global variable can only be accessed in a privileged context):

 

var oDoc=app.newDoc();

oDoc.saveAs("/*the path where you want the pdf saved*/");
var data=global.page_Count.replace(/--/g,"\r");
oDoc.createDataObject("myList.txt",data);//creates text list attachment
oDoc.viewState = {overViewMode:7};//opens the attachment panel

delete global.page_Count;