How to get the number of pages of a PDF file created through Workflow

Hello everyone,

is there a way to get the number of pages of a PDF file created through the workflow? I need to create multiple conditions based on the number of pages a PDF contains, but I can’t find a proper way to do it. Here is an example of what I am trying to achieve:

I found a “solution” but it requires another process using the PDF file as an input to work. I would like to only have one process if possible. Here is the solution:

Split PDF on Pages

thanks

There’s a simpler way to do this inside of a Connect process. Essentially, Connect already knows how many pages there are, so it’s just a question of running a query against the REST api. You can find an example here: Global page count - Workflow - Upland OL User community

Wow, using a splitter is an eurrr… interesting idea. :wink:

But a simple 4-line script would do it.

var myPDF = Watch.GetPDFEditObject();
myPDF.Open(Watch.GetJobFileName(), false);
Watch.SetVariable("%{PageCount}", myPDF.Pages.Count());
myPDF.Close();

I wrote that from the top of my head, so it certainly won’t work as-is. But you get the gist of it.

References:

@fortiny: the post quoted by @AlbertsN does not use a splitter, it uses the REST call that returns the total number of pages and documents in a job. It also includes, later in the same post, the same code you presented, but that will only work when the PDF has already been created and returned to Workflow, which is not always the case as demonstrated by the original poster’s Workflow diagram.

My comment regarding splitter referred to the original question, not AlbertsN’s answer. :wink: It’s actually one of the more creative uses of Workflow I’ve seen.

My answer assumed that the PDF already exists because of the splitter-based solution that’s already implemented. But yes, if it fits in the whole workflow process, getting it straight from Connect is definitely a good solution as well.

Thank you fortiny,

Your script worked and is by far better than my solution. I found this link where there is your solution both in javascript and vbscript.