how to generate a pdf file in php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kamill
    New Member
    • Dec 2006
    • 71

    #1

    how to generate a pdf file in php

    i m using php5 on windows.
    my code is following:
    [CODE=php]
    <?php
    // create handle for new PDF document
    $pdf = pdf_new();

    // open a file
    pdf_open_file($ pdf, "philosophy.pdf ");

    // start a new page (A4)
    pdf_begin_page( $pdf, 595, 842);
    //$arial="Arial";
    // get and use a font object
    $font = pdf_findfont($p df, "arial", "winansi", 1);
    if ($font) {
    pdf_setfont($pd f, $font, 10);
    }

    // print text
    pdf_show_xy($pd f, "There are more things in heaven and earth, Horatio,", 50, 750); pdf_show_xy($pd f, "than are dreamt of in your philosophy", 50, 730);

    // end page
    pdf_end_page($p df);

    // close and save file
    pdf_close($pdf) ;
    ?>

    [/CODE]
    Fatal error: Uncaught exception 'PDFlibExceptio n' with message 'Metrics data for font 'arial' not found' in C:\PHP\xampp\ht docs\working\pd f.php:12 Stack trace: #0 C:\PHP\xampp\ht docs\working\pd f.php(12): pdf_findfont() #1 {main} thrown in C:\PHP\xampp\ht docs\working\pd f.php on line 12
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, kamill.

    Are you using PDFlib Lite? You can only use the barebones built-in fonts with PDFlib Lite:

    Comment

    Working...