"Fossies" - the Fresh Open Source Software Archive

Member "PDFlib-Lite-7.0.5p3/bind/pdflib/perl/hello.pl" (6 Jun 2012, 1152 Bytes) of package /linux/misc/old/PDFlib-Lite-7.0.5p3.tar.gz:


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

    1 #!/usr/bin/perl
    2 # $Id: hello.pl,v 1.27 2006/10/01 19:55:11 rjs Exp $
    3 #
    4 # PDFlib client: hello example in Perl
    5 #
    6 
    7 use pdflib_pl 7.0;
    8 
    9 $p = PDF_new();
   10 
   11 eval {
   12     # This means we must check return values of load_font() etc.
   13     PDF_set_parameter($p, "errorpolicy", "return");
   14 
   15     # This line is required to avoid problems on Japanese systems
   16     PDF_set_parameter($p, "hypertextencoding", "winansi");
   17 
   18     if (PDF_begin_document($p, "hello.pdf", "") == -1) {
   19     die("Error: %s\n", PDF_get_errmsg($p));
   20     }
   21 
   22     PDF_set_info($p, "Creator", "hello.pl");
   23     PDF_set_info($p, "Author", "Thomas Merz");
   24     PDF_set_info($p, "Title", "Hello world (Perl)!");
   25 
   26     PDF_begin_page_ext($p, 595, 842, "");
   27 
   28     $font = PDF_load_font($p, "Helvetica-Bold", "winansi", "");
   29     if ($font == -1) {
   30     die("Error: %s\n", PDF_get_errmsg($p));
   31     }
   32 
   33     PDF_setfont($p, $font, 24.0);
   34     PDF_set_text_pos($p, 50, 700);
   35     PDF_show($p, "Hello world!");
   36     PDF_continue_text($p, "(says Perl)");
   37     PDF_end_page_ext($p, "");
   38 
   39     PDF_end_document($p, "");
   40 };
   41 
   42 if ($@) {
   43     printf("hello: PDFlib Exception occurred:\n");
   44     printf(" $@\n");
   45     exit;
   46 }
   47 
   48 PDF_delete($p);