priPrinter: Sub-Booklet helper script - priPrinter

Jump to content

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

Sub-Booklet helper script

#1 User is offline   Aron 

  • priPrinter Support
  • Group: Administrators
  • Posts: 132
  • Joined: 28-February 10

Posted 09 June 2013 - 07:56 PM

Script may be helpful, if you want to define number of sub-booklets instead of number of sheets per single sub-booklet.
Script calculates current number of sub-booklets and prompts user for new number of sub-booklets.
This scripts may be installed by dropping file onto priPrinter window.

/*
subbooklet calculator
filename="SubBookCalc"
toolbar.Icon=13
*/

function GetNumSubBooklets(sheets, perbooklet)
{
	local _max=(sheets/perbooklet);	
	if(sheets%perbooklet)_max++;
	return _max;
}


local doc=window.GetDocument();

if(layout.mode!="Booklet")
{
  local id=MsgBox("You are not in booklet mode.\nDo you want to switch to booklet mode?",3);
  //print("booklet:" + id);
  if(id==6)
	layout.mode="Booklet";
else return;
}
if(!layout.blSub)
{
  local id=MsgBox("You are not in sub-booklet mode.\nDo you want to switch to sub-booklet mode?",3); 
  if(id==6)
	layout.blSub=true;
 else return;
}

local numPapers=layout.GetNumSheets();

local num=layout.blSheetsPerBooklet*2;
local _max=GetNumSubBooklets(numPapers, 2);
local _current=GetNumSubBooklets(numPapers, num);
//print(numPapers+":"+num+"="+_current);

local sel=InputBox("Number of sub-booklets. From 1 to " +_max,_current.tostring());
if(sel)
{
  local _numSub=sel.tointeger();
  if(_numSub!=0)
  {
	 local _numSub2=_numSub*2;
     local SheetsPerBooklet=numPapers/_numSub2;
 	 if(numPapers%_numSub2)
		 SheetsPerBooklet++;

	 local _new=GetNumSubBooklets(numPapers, SheetsPerBooklet*2);
	 if(_new!=_numSub)
	 {
		local id=MsgBox("Looks like we can set number of sub-booklets to "+_new+" only :(/>/>/>\nDo you want to proceed?",3);
		if(id!=6)return;
	 }
	 if(num!=SheetsPerBooklet){
		 layout.blSheetsPerBooklet=SheetsPerBooklet;		 
	 }
  }
}

Attached Image: shot_cmd.png
0

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