Page 1 of 1

Rounded trimbox values as PrivateData

Posted: Mon Feb 28, 2022 4:59 pm
by magnussandstrom
Hi, I need to round incoming PDF trimbox to whole millimetres without decimals.

If the trimbox of the incoming PDF is 50,4x50,5 mm I need the result in my PrivateData to be 50x51. I'm guessing that I need to use Stats.TrimBoxWidth and Stats.TrimBoxHeight and Switch Calculation some how?

Re: Rounded trimbox values as PrivateData

Posted: Mon Feb 28, 2022 5:39 pm
by nna
You can use the round-function with the calculations. So your variable construction could look something like this:

Code: Select all

[Switch.Calculation:Expression="round([Stats.TrimBoxWidth:Type="Defined"])"]x[Switch.Calculation:Expression="round([Stats.TrimBoxHeight:Type="Defined"])"]
Depending on your settings I think you might need to calculate the width and height from points to mm within the other calculation.

Re: Rounded trimbox values as PrivateData

Posted: Mon Feb 28, 2022 8:32 pm
by magnussandstrom
Thanks! I did it in two steps, it seems to be working.

In the first folder (PrivateData) convert to mm:

Code: Select all

width_mm=[Switch.Calculation:Expression="[Stats.TrimBoxWidth:Type="Defined"]/2.83465"]
height_mm=[Switch.Calculation:Expression="[Stats.TrimBoxHeight:Type="Defined"]/2.83465"]
The second folder (PrivateData) round mm:

Code: Select all

new_size=[Switch.Calculation:Expression="round([Job.PrivateData:Key="width_mm"])"]x[Switch.Calculation:Expression="round([Job.PrivateData:Key="height_mm"])"]
Please enlighten me if there is a better way!

Re: Rounded trimbox values as PrivateData

Posted: Tue Mar 01, 2022 1:37 pm
by nna
You could combine both steps into one:

Code: Select all

new_size=[Switch.Calculation:Expression="round([Switch.Calculation:Expression="[Stats.TrimBoxWidth:Type="Defined"]/2.83465"])"]x[Switch.Calculation:Expression="round([Switch.Calculation:Expression="[Stats.TrimBoxHeight:Type="Defined"]/2.83465"])"]

Re: Rounded trimbox values as PrivateData

Posted: Fri Mar 04, 2022 1:22 pm
by magnussandstrom
Thank you that works great!