// paper size, use A4
lMaxWidth=1056;
lMaxHeight=816;
// create a new XPS file, with a single document
lNewXPS=new NOPackage();
lNewXPS=lNewXPS.create(true,"spreads.xps");
lNewDoc=lNewXPS.getDocument(0);
// get the doc
lDocument=App.getDocument();
lNumberOfPages=lDocument.getNumberOfPages();
for (i=0; i<lNumberOfPages; i++)
{
if (i % 2==0)
{
// create a new page
lNewPage=lNewDoc.createPage();
lNewFixedPage=lNewPage.getFixedPage();
lNewFixedPage.setWidth(lMaxWidth);
lNewFixedPage.setHeight(lMaxHeight);
lOffsetX=0;
lNum=0;
} else
{
lOffsetX=lMaxWidth/2;
lNum=1;
}
// access the page
lPage=lDocument.getPage(i);
lFixedPage=lPage.getFixedPage();
lPageWidth=lFixedPage.getWidth();
lPageHeight=lFixedPage.getHeight();
// calculate the factor
lFactorWidth=(lMaxWidth/2)/lPageWidth;
lFactorHeight=lMaxHeight/lPageHeight;
lFactor=lFactorWidth;
if (lFactorHeight<lFactor)
lFactor=lFactorHeight;
// copy page on top
lNewPage.copyPageOnTop(lPage);
lCanvas=lNewFixedPage.getCanvas(lNum);
lCanvas.setRenderTransform(lFactor+",0,0,"+lFactor+","+lOffsetX+",0");
}
App.addPackage(lNewXPS);
Subscribe to
Posts [Atom]