priPrinter: Print Machine - priPrinter

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Print Machine

#1 User is offline   Alex 

  • Administrator
  • Group: Administrators
  • Posts: 238
  • Joined: 28-February 10
  • LocationHungary

Posted 04 August 2012 - 04:13 PM

The goal is to combine pages from many small jobs into one, relatively big job and print this job to a printer after reaching some limit. In other words I'm thinking about some sort of a FIFO buffer, which is filled by incoming pages. When number of pages in the buffer is greater than some amount, this number of pages should be flushed to a printer. In this case output job will always contain exact number of pages, and in case of N-Up layout, paper sheets will be fully filled by source pages.

priPrinter allows to run script for each new incoming job, so we are going to create script which will implement this buffer.
Script is a text file with .psf extension. This file should be placed in a special folder, so priPrinter will be able to execute it for each printout.

This is the full code:
local doc=window.GetDocument();
if(doc && doc.numpages) // avoid call on empty document
{
  const Min=5;
  while(1)
  {
  local N= layout.GetNumSheets();// How many sheets do we have?
  if(N>=Min)
  {	  
	 if(N==Min) // Is the last sheet fully covered by source pages?
	 {
	 local paper0=layout.GetSheet(0);
	 local paper1=layout.GetSheet(N-1);
	 if(paper0.GetNumPages()!=paper1.GetNumPages()) // we can check it by comparing number of pages
		 break;
	 }
     N=Min;
     layout.Print({dialog=false, from=0, to=N-1,duplex=0}); // print N pages to printer
	 local i;
	 local pagesToRemove=0;// Calculate number of pages to remove
	 for(i=0;i<N;i++)
	 {
	 local paper=layout.GetSheet(i);
	 pagesToRemove+=paper.GetNumPages();
	 }
	 
	 while(doc.GetNumSubDocs())
	 {
		local subDoc=doc.GetSubDoc(0);
		local c=subDoc.GetNumPages();
		if(c<=pagesToRemove)// Can we delete this job?
		{
			doc.DeleteSubDoc(0);
			pagesToRemove-=c;
		}else
		{  // delete pages only
			for(i=0;i<pagesToRemove;i++)			
				subDoc.DeletePage(0);			
			break;
		}
	 }  
  }else break;
  }  
}

This script always print pages by portions, even in case if number of pages is few times larger than required amount.
So script is executed after arriving new job.
Script check: how many sheets do we have. In case if number is larger than 5 we can print 5 sheets to printer. In case if number of sheets is exactly 5, it should check last sheet. If this sheet is fully covered, we can print these 5 sheets as well.
Next it deletes source pages or jobs.
-2

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users