home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 February / PCWorld_2002-02_cd.bin / Software / Vyzkuste / pdflib / pdflib-4.0.1.sit / pdflib-4.0.1 / bind / python / quickreference.py < prev    next >
Encoding:
Python Source  |  2001-07-04  |  1.5 KB  |  71 lines  |  [TEXT/Pyth]

  1. #!/usr/bin/python
  2. # $Id: quickreference.py,v 1.3 2001/04/18 09:41:16 tm Exp $
  3. #
  4. # PDFlib/PDI client: mini imposition demo
  5. #
  6.  
  7. from sys import *
  8. from pdflib_py import *
  9.  
  10. p = PDF_new()
  11.  
  12. if PDF_open_file(p, "quickreference.pdf") == -1:
  13.     print "Couldn't open PDF file 'quickreference.pdf'\n"
  14.     exit(2)
  15.  
  16. PDF_set_info(p, "Author", "Thomas Merz")
  17. PDF_set_info(p, "Creator", "quickreference.py")
  18. PDF_set_info(p, "Title", "mini imposition demo (Python)")
  19.  
  20. infile = "../../doc/PDFlib-manual.pdf"
  21. manual = PDF_open_pdi(p, infile, "", 0)
  22.  
  23. if manual == -1:
  24.     print "Couldn't open input file '" + infile + "'\n"
  25.     exit(2)
  26.  
  27. maxrow = 2
  28. maxcol = 2
  29. startpage = 122
  30. endpage = 125
  31. width = 500.0
  32. height = 770.0
  33.  
  34. row = 0
  35. col = 0
  36.  
  37. for pageno in range(startpage, endpage+1):
  38.     if row == 0 and col == 0:
  39.     PDF_begin_page(p, width, height)
  40.     font = PDF_findfont(p, "Helvetica-Bold", "host", 0)
  41.     PDF_setfont(p, font, 18)
  42.     PDF_set_text_pos(p, 25, height-24)
  43.     PDF_show(p, "PDFlib 4.0 Quick Reference")
  44.  
  45.     page = PDF_open_pdi_page(p, manual, pageno, "")
  46.  
  47.     if page == -1:
  48.     print "Couldn't open page", pageno, "in '" + infile + "'.\n"
  49.     exit(2)
  50.  
  51.     PDF_place_pdi_page(p, page, width/maxcol*col, height - (row + 1) 
  52.             * height/maxrow, 1.0/maxrow, 1.0/maxrow)
  53.     PDF_close_pdi_page(p, page)
  54.  
  55.     col = col+1
  56.     if col == maxcol:
  57.     col = 0
  58.     row = row+1
  59.  
  60.     if row == maxrow:
  61.     row = 0
  62.     PDF_end_page(p)
  63.  
  64. # finish the last partial page
  65. if row != 0 or col != 0:
  66.     PDF_end_page(p)
  67.  
  68. PDF_close(p)
  69. PDF_close_pdi(p, manual)
  70. PDF_delete(p)
  71.