מדריך PHP
קודם
הבא
Please see the PDFlib installation section for more information about compiling PDF support into PHP.
Please note that most of the PDF functions require a pdf object as it 's first parameter.
הערה:
Note that ClibPDF has a slightly different API compared to PDFlib.
For compatibility reasons this binding for PDFlib still supports the old functions, but they should be replaced by their new versions.
טבלה 1.
Deprecated functions and its replacements
The most difficult part is probably creating a very simple PDF document at all.
The following example should help to get started.
It creates test.pdf with one page.
דוגמה 1.
?php $pdf = pdf_new(); pdf_open_file($pdf, "test.pdf"); pdf_set_info($pdf, "Author", "Uwe Steinmann"); pdf_set_info($pdf, "Title", "Test for PHP wrapper of PDFlib 2.0"); pdf_set_info($pdf, "Creator", "See Author"); pdf_set_info($pdf, "Subject", "Testing"); pdf_begin_page($pdf, 595, 842); pdf_add_outline($pdf, "Page 1"); pdf_set_font($pdf, "Times-Roman", 30, "host"); pdf_set_value($pdf, "textrendering", 1); pdf_show_xy($pdf, "Times Roman outlined", 50, 750); pdf_moveto($pdf, 50, 740); pdf_lineto($pdf, 330, 740); pdf_stroke($pdf); pdf_end_page($pdf); pdf_close($pdf); pdf_delete($pdf); echo "A HREF=getpdf.php finished / A";?
Here we use the in memory creation feature of PDFlib to alleviate the need to use temporary files.
The example, converted to PHP from the PDFlib example, is as follows: (The same example is available in the CLibPDF documentation.)
דוגמה 2. pdfclock example from PDFlib distribution
קודם
ראשי
הבא
למעלה