Global page count

Hello - does anyone know if or when the global page count will be available in the workflow?

Thank you

It’s already available, but you need a script to call the REST API in order to obtain the page count and the document count.

Here’s what the JavaScript code would look like:

var xhr = new ActiveXObject("Microsoft.XmlHttp");
var setID = Watch.ExpandString("GetMeta(_vger_contentset_id[0], 10, Job.Group[0])")
xhr.open("GET","http://localhost:9340/rest/serverengine/entity/contentsets/"+setID+"/pages?detail=true",false,"ol-admin","secret");
xhr.send();
var totalPages = 0;
if(xhr.status==200){
  var job = JSON.parse(xhr.responseText);
  var totalDocuments = job.length;
  for(var i=0;i<totalDocuments;i++){
    totalPages+=job[i].pages[0].count;
  }
}
Watch.Log("Documents : "+totalDocuments,2);
Watch.Log("Pages     : "+totalPages,2);

You would run that code immediately after the Create Print Content task.

2 Likes

Thank you! Question though. My workflow consists for 6 different templates creating 6 pdfs and merging them in the end into one .pdf output. the page numbers would vary depending on the data.

Where would I run this code in this situation?

thanks

The total number of pages in a PDF can already be obtained through a very simple script in Workflow:

var myPDF = Watch.GetPDFEditObject();
myPDF.Open(Watch.GetJobFilename(),false);
Watch.Log(myPDF.Pages().Count(),2);

Run that script after you’ve generated your final PDF.

After your Send to Folder that merges the final PDF add a Folder Capture with Archive Attribute on, then the script to count the pages followed by a Delete Plugin or Email or Create File depending on what you want to do to the page count.

Regards,

S

Thank you for all your help!!!