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 / perl / personalize.pl < prev    next >
Encoding:
Perl Script  |  2001-07-04  |  2.0 KB  |  72 lines  |  [TEXT/McPL]

  1. #!/usr/bin/perl
  2. # $Id: personalize.pl,v 1.7 2001/04/18 10:16:13 tm Exp $
  3. #
  4. # PDFlib/PDI client: personalization demo
  5. #
  6.  
  7. use pdflib_pl 4.0;
  8.  
  9. $col1 = 70;
  10. $col2 = 335;
  11. $infile = "../../doc/PDFlib-purchase-order.pdf";
  12.  
  13. $p = PDF_new();
  14.  
  15. if (PDF_open_file($p, "personalize.pdf") == -1) {
  16.     printf(STDERR "Error: cannot open PDF file personalize.pdf.\n");
  17.     exit(2);
  18. }
  19.  
  20. PDF_set_info($p, "Creator", "personalize.pl");
  21. PDF_set_info($p, "Author", "Thomas Merz");
  22. PDF_set_info($p, "Title", "PDFlib personalization demo (Perl)");
  23.  
  24. $form = PDF_open_pdi($p, $infile, "", 0);
  25. if ($form == -1) {
  26.     printf(STDERR "Couldn't open input file '%s'.\n", $infile);
  27.     exit(2);
  28. }
  29.  
  30. $page = PDF_open_pdi_page($p, $form, 1, "");
  31. if ($page == -1) {
  32.     printf(STDERR "Couldn't open page 1 in '%s'.\n", $infile);
  33.     exit(2);
  34. }
  35.  
  36. $font = PDF_findfont($p, "Helvetica-Bold", "host", 0);
  37.  
  38. # get the dimensions of the imported form
  39. $width = PDF_get_pdi_value($p, "width", $form, $page, 0);
  40. $height = PDF_get_pdi_value($p, "height", $form, $page, 0);
  41.  
  42. PDF_begin_page($p, $width, $height);
  43. PDF_place_pdi_page($p, $page, 0, 0, 1, 1);
  44. PDF_close_pdi_page($p, $page);
  45.  
  46. PDF_setfont($p, $font, 18);
  47. PDF_set_value($p, "leading", 24);
  48. PDF_set_text_pos($p, $col1, 486);
  49.  
  50. PDF_show($p, "Doublecheck, Inc.");
  51. PDF_continue_text($p, "Petra Porst");
  52. PDF_continue_text($p, "500, Market St.");
  53. PDF_continue_text($p, "94110 San Francisco, CA");
  54. PDF_continue_text($p, "");
  55. PDF_continue_text($p, "USA");
  56. PDF_continue_text($p, "+1/950/123-4567");
  57. PDF_continue_text($p, "+1/950/123-4568");
  58. PDF_continue_text($p, "");
  59. PDF_continue_text($p, "petra\@doublecheck.com");
  60.  
  61. ($tm_sec,$tm_min,$tm_hour,$tm_mday,$tm_mon,$tm_year) = localtime(time);
  62. PDF_set_text_pos($p, $col2, 152);
  63. PDF_continue_text($p, sprintf("%s %d, %d",
  64.     ("January", "February", "March", "April", "May", "June",
  65.     "July", "August", "September", "October", "November", "December")
  66.             [$tm_mon], $tm_mday, 1900 + $tm_year));
  67.  
  68. PDF_end_page($p);
  69. PDF_close($p);
  70. PDF_close_pdi($p, $form);
  71. PDF_delete($p);
  72.