Rounded trimbox values as PrivateData

Post Reply
User avatar
magnussandstrom
Advanced member
Posts: 345
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Rounded trimbox values as PrivateData

Post 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?
nna
Member
Posts: 30
Joined: Tue Jul 21, 2020 9:57 am

Re: Rounded trimbox values as PrivateData

Post 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.
User avatar
magnussandstrom
Advanced member
Posts: 345
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Re: Rounded trimbox values as PrivateData

Post 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!
nna
Member
Posts: 30
Joined: Tue Jul 21, 2020 9:57 am

Re: Rounded trimbox values as PrivateData

Post 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"])"]
User avatar
magnussandstrom
Advanced member
Posts: 345
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Re: Rounded trimbox values as PrivateData

Post by magnussandstrom »

Thank you that works great!
Post Reply