cancel
Showing results for 
Search instead for 
Did you mean: 
shiu
Member
Member

Variables calculation

Hello

I have to print a PDF that contains certain number of sets of letter, each set has the same number of pages, how can I use the variables to calculate the number of sets and print the result on the first page of the pdf?

For example a pdf is dropped in the hot folder, the total number of pages is defined by the variable $FFwfDoc.pages$, that is 72 and it's already known that each set of letter contains 8 pages, so there should be 9 sets of letter, my question is how can I use the variable to calculate the result and print it on the first page of the pdf. I use a watermark node with the contents as text “Number of letter sets: $FFwfDoc.pages$/8”, but when it prints out it doesn’t show the result of 9, instead it just show the formular that I entered in the watermark node, is there a way to do as what I expected?

0 Kudos
5 Replies
StefanT-Xerox
FreeFlow Production Workflow Moderator
FreeFlow Production Workflow Moderator

Re: Variables calculation

Here is an idea. Split the job into fixed 8 page segments. Use Route to check if the segment is the first one. In that case add a Watermark using the $FFwfJob.documentGroupCount$ variable on the first page. Then Join the segments back together.

0 Kudos
StefanT-Xerox
FreeFlow Production Workflow Moderator
FreeFlow Production Workflow Moderator

Re: Variables calculation

Alternatively you can do this with a script. Please see attached. It uses Python that needs to be installed with pikepdf and reportlab (pip install from cmd as admin). Point to the batch file in an External Process in a workflow using the parameters:

"$FFin$" "$FFout$" "$FFwfJob.jobName$"

Check the paths to Python and the FreeFlow Core Scripts folder in the batch file. The Python script assumes there is a C:\Temp\ folder.

This line in the Python script controls what will be printed on the first page and where on the page it will be printed:

can.drawString(200, 450, "Number of letter sets: " + str(int(numberofpages/8)))

 

 

 

0 Kudos
DavidU54339-XRX
FreeFlow Production Workflow Moderator
FreeFlow Production Workflow Moderator

Re: Variables calculation

In early 2Q 2021, FFCore 6.1.0 will enable the following solution (via an upgrade of the External node). See screensnaps and attached .bat file (needs filename extension changed to .bat).

set.pngset2.png

 

0 Kudos
shiu
Member
Member

Re: Variables calculation

Hi Stefan,

I'm not familar with the Python scripting, so I use this first method you suggested, this worked pretty good however in the case when the input batch file has only 1 set of letter in it, the result shows 0 but not 1, how can I fix this? 

Thanks.

0 Kudos
StefanT-Xerox
FreeFlow Production Workflow Moderator
FreeFlow Production Workflow Moderator

Re: Variables calculation

When the job has less than or equal to 8 pages it is never split, so the variable $FFwfJob.documentGroupCount$ is zero.

You could place a Route first that checks if the job has 8 pages or less and in that case hard code letter sets to 1 in another watermark.

variable calc.PNG

 

 

0 Kudos