Page 1 of 1

How to calculate Ratio for multiple numbers in JS?

Posted: Thu Jun 25, 2020 10:58 pm
by Zoranj
I have a need to gang impose multiple items on the sheet but no license for Sheet Optimizer.
Javascript can do it from my googling but all examples are for 2 numbers, I might have 5 or more items.
Has anyone done something similar?

Thanks

Re: How to calculate Ratio for multiple numbers in JS?

Posted: Thu Jul 09, 2020 10:32 am
by ThomasDeschamps
The item are all the same size? or do you have different item?

if it's the same item size, it's rather simple, something like this will return an object with your number of column and row.
You can also add a function to test with a rotation, if the grain direction is not a problem.

Code: Select all

function calculateImposition(sheetWidth, fileWidth, sheetHeight, fileHeight) {
	return {
		column : Math.floor(sheetWidth / fileWidth ),
		row : Math.floor(sheetHeight / fileHeight ),
	};
}
If different item size, it's a lot more difficult task (are they all square? do you need to follow specific rule like grain direction? is it possible to rotate PDF? etc etc..)

Re: How to calculate Ratio for multiple numbers in JS?

Posted: Thu Jul 09, 2020 2:29 pm
by Zoranj
Thanks Thomas for reply.

Yes, to make it easier they are same size, however it is the ratio that is the problem.
Even with same size, there are multiple different items with different quantities so e.g.:
Item a is 1000
item b is 2000
item c is 3000
item d is 3000
so on 16up sheet I need to impose 2up of a, 4up of b, 5 up of c and 5up of d.

I can do this manually, as in I made excel calculator for ratio, but I wanted to automate it.
There could be different number of times and different quantities all the time.

Re: How to calculate Ratio for multiple numbers in JS?

Posted: Thu Jul 09, 2020 3:18 pm
by jan_suhr
If all jobs are the same you can use an App for that to combine the files into a factor of the number of prints for each job.
The App in question is Duplicate Pages PRO.

In the example below, the green and magenta jobs are 300 and the yellow is 200 and you print 100 sheets.
In the flow you upload the jobfiles through a submit point, you set the factor, a job indentifyer (to assemble the jobs to one sheet) and how many jobs on one sheet.
Screenshot 2020-07-09 15.04.02.png
Screenshot 2020-07-09 15.04.02.png (54.41 KiB) Viewed 8126 times
Screenshot 2020-07-09 15.07.54 copy.jpg
Screenshot 2020-07-09 15.07.54 copy.jpg (86.01 KiB) Viewed 8126 times

Re: How to calculate Ratio for multiple numbers in JS?

Posted: Thu Jul 09, 2020 4:16 pm
by ThomasDeschamps
Zoranj wrote: Thu Jul 09, 2020 2:29 pm Even with same size, there are multiple different items with different quantities so e.g.:
Item a is 1000
item b is 2000
item c is 3000
item d is 3000
so on 16up sheet I need to impose 2up of a, 4up of b, 5 up of c and 5up of d.

With this exemple, you don't get 3000 ex of C and D, but 2500?

Re: How to calculate Ratio for multiple numbers in JS?

Posted: Thu Jul 09, 2020 9:16 pm
by Zoranj
Thanks Jan, I will take a look at the app.
Thomas, you are correct that it is 2500, I just pulled numbers out of blue, maybe not best example but in such case you would print 600 sheets to get 3000 for C and D, while having waste on a and b items.

Proper imposition software calculates ratios much better and some even give you option to use more sheets or less plates, which produces more or less waste, etc...
I used Signa sheet optimizer for this specific task and it is quite powerful, another software that comes to mind is Phoenix and Ultimate from what I read online.

Re: How to calculate Ratio for multiple numbers in JS?

Posted: Thu Jul 09, 2020 10:07 pm
by jan_suhr