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 / php / quickreference.php < prev    next >
Encoding:
PHP Script  |  2001-04-18  |  1.6 KB  |  77 lines  |  [TEXT/LMAN]

  1. <?php
  2. # $Id: quickreference.php,v 1.6 2001/04/18 09:41:16 tm Exp $
  3.  
  4. $infile = "PDFlib-manual.pdf";
  5. $maxrow = 2;
  6. $maxcol = 2;
  7. $pagecount = 4;
  8. $width = 500.0;
  9. $height = 770.0;
  10. $startpage = 122;
  11. $endpage = 125;
  12.  
  13. $p = PDF_new();
  14.  
  15. PDF_open_file($p, "");
  16.  
  17. PDF_set_info($p, "Creator", "quickreference.php");
  18. PDF_set_info($p, "Author", "Thomas Merz");
  19. PDF_set_info($p, "Title", "mini imposition demo (php)");
  20.  
  21. $manual = PDF_open_pdi($p, $infile, "", 0);
  22. if (!$manual) {
  23.     die("Couldn't open input file '%s'".$infile);
  24. }
  25.  
  26. $row = 0;
  27. $col = 0;
  28.  
  29. for ($pageno = $startpage; $pageno <= $endpage; $pageno++) {
  30.     if ($row == 0 && $col == 0) {
  31.     PDF_begin_page($p, $width, $height);
  32.     $font = PDF_findfont($p, "Helvetica-Bold", "host", 0);
  33.     PDF_setfont($p, $font, 18);
  34.     PDF_set_text_pos($p, 25, $height-24);
  35.     PDF_show($p, "PDFlib 4.0 Quick Reference");
  36.     }
  37.  
  38.     $page = PDF_open_pdi_page($p, $manual, $pageno, "");
  39.  
  40.     if (!$page) {
  41.     die("Couldn't open page $pageno in '$infile'.\n");
  42.     }
  43.  
  44.     PDF_place_pdi_page($p, $manual, $width/$maxcol*$col, $height - ($row + 1)
  45.             * $height/$maxrow, 1/$maxrow, 1/$maxrow);
  46.     PDF_close_pdi_page($p, $page);
  47.  
  48.     $col++;
  49.     if ($col == $maxcol) {
  50.     $col = 0;
  51.     $row++;
  52.     }
  53.     if ($row == $maxrow) {
  54.     $row = 0;
  55.     PDF_end_page($p);
  56.     }
  57. }
  58.  
  59. # finish the last partial page
  60. if ($row != 0 || $col != 0) {
  61.     PDF_end_page($p);
  62. }
  63.  
  64. PDF_close($p);
  65. PDF_close_pdi($p, $manual);
  66.  
  67. $buf = PDF_get_buffer($p);
  68. $len = strlen($buf);
  69.  
  70. header("Content-type: application/pdf");
  71. header("Content-Length: $len");
  72. header("Content-Disposition: inline; filename=hello_php.pdf");
  73. print $buf;
  74.  
  75. PDF_delete($p);
  76. ?>
  77.