LXXV. PDF functions

Introduction

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 .

Confusion with old PDFlib versions

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



Examples

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






תוכן העניינים:
pdf_add_annotation -- Deprecated: Adds annotation
pdf_add_bookmark -- Adds bookmark for current page
pdf_add_launchlink -- Add a launch annotation for current page
pdf_add_locallink -- Add a link annotation for current page
pdf_add_note -- Add a note annotation for current page
pdf_add_outline -- Deprecated: Adds bookmark for current page
pdf_add_pdflink -- Adds file link annotation for current page
pdf_add_thumbnail -- Adds thumbnail for current page
pdf_add_weblink -- Adds weblink for current page
pdf_arc -- Draws an arc (counterclockwise)
pdf_arcn -- Draws an arc (clockwise)
pdf_attach_file -- Adds a file attachement for current page
pdf_begin_page -- Starts new page
pdf_begin_pattern -- Starts new pattern
pdf_begin_template -- Starts new template
pdf_circle -- Draws a circle
pdf_clip -- Clips to current path
pdf_close -- Closes a pdf object
pdf_close_image -- Closes an image
pdf_close_pdi -- Close the input PDF document
pdf_close_pdi_page -- Close the page handle
pdf_closepath -- Closes path
pdf_closepath_fill_stroke -- Closes, fills and strokes current path
pdf_closepath_stroke -- Closes path and draws line along path
pdf_concat -- Concatenate a matrix to the CTM
pdf_continue_text -- Outputs text in next line
pdf_curveto -- Draws a curve
pdf_delete -- Deletes a PDF object
pdf_end_page -- Ends a page
pdf_end_pattern -- Finish pattern
pdf_end_template -- Finish template
pdf_endpath -- Deprecated: Ends current path
pdf_fill -- Fills current path
pdf_fill_stroke -- Fills and strokes current path
pdf_findfont -- Prepare font for later use with pdf_setfont() .
pdf_get_buffer -- Fetch the buffer containig the generated PDF data.
pdf_get_font -- Deprecated: font handling
pdf_get_fontname -- Deprecated: font handling
pdf_get_fontsize -- Deprecated: font handling
pdf_get_image_height -- Returns height of an image
pdf_get_image_width -- Returns width of an image
pdf_get_majorversion -- Returns the major version number of the PDFlib
pdf_get_minorversion -- Returns the minor version number of the PDFlib
pdf_get_parameter -- Gets certain parameters
pdf_get_pdi_parameter -- Get some PDI string parameters
pdf_get_pdi_value -- Gets some PDI numerical parameters
pdf_get_value -- Gets certain numerical value
pdf_initgraphics -- Resets graphic state
pdf_lineto -- Draws a line
pdf_makespotcolor -- Makes a spotcolor
pdf_moveto -- Sets current point
pdf_new -- Creates a new pdf object
pdf_open -- Deprecated: Open a new pdf object
pdf_open_CCITT -- Opens a new image file with raw CCITT data
pdf_open_file -- Opens a new pdf object
pdf_open_gif -- Deprecated: Opens a GIF image
pdf_open_image -- Versatile function for images
pdf_open_image_file -- Reads an image from a file
pdf_open_jpeg -- Deprecated: Opens a JPEG image
pdf_open_memory_image -- Opens an image created with PHP's image functions
pdf_open_pdi -- Opens a PDF file
pdf_open_pdi_page -- Prepare a page
pdf_open_png -- Deprecated: Opens a PNG image
pdf_open_tiff -- Deprecated: Opens a TIFF image
pdf_place_image -- Places an image on the page
pdf_place_pdi_page -- Places an image on the page
pdf_rect -- Draws a rectangle
pdf_restore -- Restores formerly saved environment
pdf_rotate -- Sets rotation
pdf_save -- Saves the current environment
pdf_scale -- Sets scaling
pdf_set_border_color -- Sets color of border around links and annotations
pdf_set_border_dash -- Sets dash style of border around links and annotations
pdf_set_border_style -- Sets style of border around links and annotations
pdf_set_char_spacing -- Deprecated: Sets character spacing
pdf_set_duration -- Deprecated: Sets duration between pages
pdf_set_font -- Deprecated: Selects a font face and size
pdf_set_horiz_scaling -- Sets horizontal scaling of text
pdf_set_info -- Fills a field of the document information
pdf_set_info_author -- Fills the author field of the document
pdf_set_info_creator -- Fills the creator field of the document
pdf_set_info_keywords -- Fills the keywords field of the document
pdf_set_info_subject -- Fills the subject field of the document
pdf_set_info_title -- Fills the title field of the document
pdf_set_leading -- Deprecated: Sets distance between text lines
pdf_set_parameter -- Sets certain parameters
pdf_set_text_pos -- Sets text position
pdf_set_text_rendering -- Deprecated: Determines how text is rendered
pdf_set_text_rise -- Deprecated: Sets the text rise
pdf_set_text_matrix -- Deprecated: Sets the text matrix
pdf_set_value -- Sets certain numerical value
pdf_set_word_spacing -- Depriciated: Sets spacing between words
pdf_setcolor -- Sets fill and stroke color
pdf_setdash -- Sets dash pattern
pdf_setflat -- Sets flatness
pdf_setfont -- Set the current font
pdf_setgray -- Sets drawing and filling color to gray value
pdf_setgray_fill -- Sets filling color to gray value
pdf_setgray_stroke -- Sets drawing color to gray value
pdf_setlinecap -- Sets linecap parameter
pdf_setlinejoin -- Sets linejoin parameter
pdf_setlinewidth -- Sets line width
pdf_setmatrix -- Sets current transformation matrix
pdf_setmiterlimit -- Sets miter limit
pdf_setpolydash -- Sets complicated dash pattern
pdf_setrgbcolor -- Sets drawing and filling color to rgb color value
pdf_setrgbcolor_fill -- Sets filling color to rgb color value
pdf_setrgbcolor_stroke -- Sets drawing color to rgb color value
pdf_show -- Output text at current position
pdf_show_boxed -- Output text in a box
pdf_show_xy -- Output text at given position
pdf_skew -- Skews the coordinate system
pdf_stringwidth -- Returns width of text using current font
pdf_stroke -- Draws line along path
pdf_translate -- Sets origin of coordinate system