Page 1 of 1

Generating a PDF file through PHP

Posted: Wed Sep 16, 2009 6:17 am
by weasel512
G'day,

I have a problem, which i really dont know much about. I'm just testing the waters here, and looking at how i can export output from php to a PDF file.

I found one tutorial, but i am getting a confusing error message.

Code: Select all

// 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);
    
    // get and use a font object
    $arial = pdf_findfont($pdf, "Courier", "host", 1);
    pdf_setfont($pdf, $arial, 10);
    
    // print text
    pdf_show_xy($pdf, "There are more things in heaven and earth, Horatio,",50, 750); 
    pdf_show_xy($pdf, "than are dreamt of in your philosophy", 50,730);
    
    // end page
    pdf_end_page($pdf);
    
    // close and save file
    pdf_close($pdf);
The error message that i am getting is:
Fatal error: Uncaught exception 'PDFlibException' with message 'No file specified with outline data for font 'Courier'' in C:\wamp\www\Creating PDFs\pdf.php:20 Stack trace: #0 C:\wamp\www\Creating PDFs\pdf.php(20): pdf_findfont(Resource id #2, 'Courier', 'host', 1) #1 {main} thrown in C:\wamp\www\Creating PDFs\pdf.php on line 20
If someone could please help me to understand, it would be much appreciated!


Cheers

Re: Generating a PDF file through PHP

Posted: Wed Sep 16, 2009 4:13 pm
by Darhazer
There was topic about PDF generation, it does not cover those functions, as far as I remember, but it have solutions you may find interesting.

Re: Generating a PDF file through PHP

Posted: Wed Sep 16, 2009 9:56 pm
by weasel512
I'm using the standard PDFLib thats supported by php4 and above..
To be honest, i'd prefer to use that, but the link you provided has some v. good points.

thx man.


If anyone knows how to effectively use the pdfLib, i'd LOVE to hear from you !



Cheers