"Fossies" - the Fresh Open Source Software Archive

Member "reportlab-3.5.23/tools/utils/add_bleed.py" (26 Mar 2014, 966 Bytes) of package /linux/privat/reportlab-3.5.23.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "add_bleed.py" see the Fossies "Dox" file reference documentation.

    1 #How to add bleed to a page in this case 6mm to a landscape A4
    2 from reportlab.lib import units, pagesizes
    3 from reportlab.pdfgen.canvas import Canvas
    4 import sys, os, glob, time
    5 bleedX = 6*units.mm
    6 bleedY = 6*units.mm
    7 pageWidth, pageHeight = pagesizes.landscape(pagesizes.A4)
    8 def process_pdf(c,infn,prefix='PageForms'):
    9     from rlextra.pageCatcher import pageCatcher
   10     names, data = pageCatcher.storeFormsInMemory(open(infn,'rb').read(),prefix=prefix,all=1)
   11     names = pageCatcher.restoreFormsInMemory(data,c)
   12     del data
   13     for i in range(len(names)):
   14         thisname = names[i]
   15         c.saveState()
   16         c.translate(bleedX,bleedY)
   17         c.doForm(thisname)
   18         c.restoreState()
   19         c.showPage()
   20 
   21 def main():
   22     for infn in sys.argv[1:]:
   23         outfn = 'bleeding_'+os.path.basename(infn)
   24         c = Canvas(outfn,pagesize=(pageWidth+2*bleedX,pageHeight+2*bleedY))
   25         process_pdf(c,infn)
   26         c.save()
   27 if __name__=='__main__':
   28     main()