PDF functions PDF You can use the PDF functions in PHP to create PDF files if you have the PDF library by Thomas Merz (available at http://www.pdflib.com/pdflib/index.html; you will also need the JPEG library and the TIFF library to compile this. These two libs also quite often make problems when configuring php. Follow the messages of configure to fix possible problems. If you use pdflib 2.01 check how the lib was installed. There should be file or link libpdf.so. Version 2.01 just creates a lib with the name libpdf2.01.so which cannot be found when linking the test programm in configure. You will have to create a symbolic link from libpdf.so to libpdf2.01.so.). Please consult the excellent documentation for pdflib shipped with the source distribution of pdflib. It provides a very good overview of what pdflib capable of doing. Most of the functions in pdflib and the PHP module have the same name. The parameters are also identical. You should also understand some of the concepts of PDF or Postscript to efficiently use this module. All lengths and coordinates are measured in Postscript points. There are generally 72 PostScript points to an inch, but this depends on the output resolution. There is another PHP module for pdf document creation based on FastIO's. ClibPDF. It has a slightly different API. Check the ClibPDF functions section for details. Currently all versions of pdflib are supported. It is recommended that you use the newest version since it has more features and fixes some problems which required a patch for the old version. Unfortunately, the changes of the pdflib API in 2.x compared to 0.6 have been so severe that even some PHP functions had to be altered. Here is a list of changes: The Info structure does not exist anymore. Therefore the function pdf_get_info is obsolete and the functions pdf_set_info_creator, pdf_set_info_title, pdf_set_info_author, pdf_set_info_subject and pdf_set_info_keywords do not take the info structure as the first parameter but the pdf document. This also means that the pdf document must be opened before these functions can be called. The way a new document is opened has changed. The function pdf_open takes only one parameter which is the file handle of a file opened with fopen. There were some more changes with the release 2.01 of pdflib which should be covered by PHP. Some functions are not required anymore (e.g. pdf_put_image). You will get a warning so don't be shocked. The pdf module introduces two new types of variables (if pdflib 2.x is used it is only one new type). They are called pdfdoc and pdfinfo (pdfinfo is not existent if pdflib 2.x is used. pdfdoc is a pointer to a pdf document and almost all functions need it as its first parameter. pdfinfo contains meta data about the PDF document. It has to be set before pdf_open is called. The following is only true for pdflib 0.6. Read the pdflib manual for newer version In order to output text into a PDF document you will need to provide the afm file for each font. Afm files contain font metrics for a Postscript font. By default these afm files are searched for in a directory named 'fonts' relative to the directory where the PHP script is located. (Again, this was true for pdflib 0.6, newer versions do not not neccessarily need the afm files.) Most of the functions are fairly easy to use. The most difficult part is probably to create a very simple pdf document at all. The following example should help to get started. It uses the PHP functions for pdflib 0.6. It creates the file test.pdf with one page. The page contains the text "Times-Roman" in an outlined 30pt font. The text is also underlined. Creating a PDF document with pdflib 0.6 <?php $fp = fopen("test.pdf", "w"); $info = PDF_get_info(); pdf_set_info_author($info, "Uwe Steinmann"); PDF_set_info_title($info, "Test for PHP wrapper of PDFlib 0.6"); PDF_set_info_author($info, "Name of Author"); pdf_set_info_creator($info, "See Author"); pdf_set_info_subject($info, "Testing"); $pdf = PDF_open($fp, $info); PDF_begin_page($pdf, 595, 842); PDF_add_outline($pdf, "Page 1"); pdf_set_font($pdf, "Times-Roman", 30, 4); pdf_set_text_rendering($pdf, 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); fclose($fp); echo "<A HREF=getpdf.php3>finished</A>"; ?> The PHP script getpdf.php3 just outputs the pdf document. <?php $fp = fopen("test.pdf", "r"); header("Content-type: application/pdf"); fpassthru($fp); fclose($fp); ?> Doing the same with pdflib 2.x looks like the following: Creating a PDF document with pdflib 2.x <?php $fp = fopen("test.pdf", "w"); $pdf = PDF_open($fp); pdf_set_info_author($pdf, "Uwe Steinmann"); PDF_set_info_title($pdf, "Test for PHP wrapper of PDFlib 2.0"); PDF_set_info_author($pdf, "Name of Author"); pdf_set_info_creator($pdf, "See Author"); pdf_set_info_subject($pdf, "Testing"); PDF_begin_page($pdf, 595, 842); PDF_add_outline($pdf, "Page 1"); pdf_set_font($pdf, "Times-Roman", 30, 4); pdf_set_text_rendering($pdf, 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); fclose($fp); echo "<A HREF=getpdf.php3>finished</A>"; ?> The PHP script getpdf.php3 is the same as above. The pdflib distribution contains a more complex example which creates a serious of pages with an analog clock. This example converted into PHP using pdflib 2.x looks as the following (you can see the same example in the documentation for the clibpdf module): pdfclock example from pdflib 2.x distribution <?php $pdffilename = "clock.pdf"; $radius = 200; $margin = 20; $pagecount = 40; $fp = fopen($pdffilename, "w"); $pdf = pdf_open($fp); pdf_set_info_creator($pdf, "pdf_clock.php3"); pdf_set_info_author($pdf, "Uwe Steinmann"); pdf_set_info_title($pdf, "Analog Clock"); while($pagecount-- > 0) { pdf_begin_page($pdf, 2 * ($radius + $margin), 2 * ($radius + $margin)); pdf_set_transition($pdf, 4); /* wipe */ pdf_set_duration($pdf, 0.5); pdf_translate($pdf, $radius + $margin, $radius + $margin); pdf_save($pdf); pdf_setrgbcolor($pdf, 0.0, 0.0, 1.0); /* minute strokes */ pdf_setlinewidth($pdf, 2.0); for ($alpha = 0; $alpha < 360; $alpha += 6) { pdf_rotate($pdf, 6.0); pdf_moveto($pdf, $radius, 0.0); pdf_lineto($pdf, $radius-$margin/3, 0.0); pdf_stroke($pdf); } pdf_restore($pdf); pdf_save($pdf); /* 5 minute strokes */ pdf_setlinewidth($pdf, 3.0); for ($alpha = 0; $alpha < 360; $alpha += 30) { pdf_rotate($pdf, 30.0); pdf_moveto($pdf, $radius, 0.0); pdf_lineto($pdf, $radius-$margin, 0.0); pdf_stroke($pdf); } $ltime = getdate(); /* draw hour hand */ pdf_save($pdf); pdf_rotate($pdf,-(($ltime['minutes']/60.0)+$ltime['hours']-3.0)*30.0); pdf_moveto($pdf, -$radius/10, -$radius/20); pdf_lineto($pdf, $radius/2, 0.0); pdf_lineto($pdf, -$radius/10, $radius/20); pdf_closepath($pdf); pdf_fill($pdf); pdf_restore($pdf); /* draw minute hand */ pdf_save($pdf); pdf_rotate($pdf,-(($ltime['seconds']/60.0)+$ltime['minutes']-15.0)*6.0); pdf_moveto($pdf, -$radius/10, -$radius/20); pdf_lineto($pdf, $radius * 0.8, 0.0); pdf_lineto($pdf, -$radius/10, $radius/20); pdf_closepath($pdf); pdf_fill($pdf); pdf_restore($pdf); /* draw second hand */ pdf_setrgbcolor($pdf, 1.0, 0.0, 0.0); pdf_setlinewidth($pdf, 2); pdf_save($pdf); pdf_rotate($pdf, -(($ltime['seconds'] - 15.0) * 6.0)); pdf_moveto($pdf, -$radius/5, 0.0); pdf_lineto($pdf, $radius, 0.0); pdf_stroke($pdf); pdf_restore($pdf); /* draw little circle at center */ pdf_circle($pdf, 0, 0, $radius/30); pdf_fill($pdf); pdf_restore($pdf); pdf_end_page($pdf); } $pdf = pdf_close($pdf); fclose($fp); echo "<A HREF=getpdf.php3?filename=".$pdffilename.">finished</A>"; ?> The PHP script getpdf.php3 just outputs the pdf document. <?php $fp = fopen($filename, "r"); header("Content-type: application/pdf"); fpassthru($fp); fclose($fp); ?> PDF_get_info Returns an empty info structure for a pdf document Description info pdf_get_info string filename The PDF_get_info function returns an empty info structure for the pdf document. It should be filled with appropriate information like the author, subject etc. of the document. This functions is not available if pdflib 2.x support is activated. See also PDF_set_info_creator, PDF_set_info_author, PDF_set_info_keywords, PDF_set_info_title, PDF_set_info_subject. PDF_set_info_creator Fills the creator field of the info structure Description void pdf_set_info_creator info info string creator The PDF_set_info_creator function sets the creator field of a pdf document. It has to be called after PDF_get_info and before PDF_open. Calling it after PDF_open will have no effect on the document. This function is not part of the pdf library. This function takes a different first parameter if pdflib 2.x support is activated. The first parameter has to be the identifier of the pdf document as returned by pdf_open. Consequently, pdf_open has to be called before this function. See also PDF_get_info, PDF_set_info_keywords, PDF_set_info_title, PDF_set_info_subject. PDF_set_info_title Fills the title field of the info structure Description void pdf_set_info_title info info string title The PDF_set_info_title function sets the title of a pdf document. It has to be called after PDF_get_info and before PDF_open. Calling it after PDF_open will have no effect on the document. This function is not part of the pdf library. This function takes a different first parameter if pdflib 2.0 support is activated. The first parameter has to be the identifier of the pdf document as returned by pdf_open. Consequently, pdf_open has to be called before this function. See also PDF_get_info, PDF_set_info_creator, PDF_set_info_author, PDF_set_info_keywords, PDF_set_info_subject. PDF_set_info_subject Fills the subject field of the info structure Description void pdf_set_info_subject info info string subject The PDF_set_info_subject function sets the subject of a pdf document. It has to be called after PDF_get_info and before PDF_open. Calling it after PDF_open will have no effect on the document. This function is not part of the pdf library. This function takes a different first parameter if pdflib 2.0 support is activated. The first parameter has to be the identifier of the pdf document as returned by pdf_open. Consequently, pdf_open has to be called before this function. See also PDF_get_info, PDF_set_info_creator, PDF_set_info_author, PDF_set_info_title, PDF_set_info_keywords. PDF_set_info_keywords Fills the keywords field of the info structure Description void pdf_set_info_keywords info info string keywords The PDF_set_info_keywords function sets the keywords of a pdf document. It has to be called after PDF_get_info and before PDF_open. Calling it after PDF_open will have no effect on the document. This function is not part of the pdf library. This function takes a different first parameter if pdflib 2.0 support is activated. The first parameter has to be the identifier of the pdf document as returned by pdf_open. Consequently, pdf_open has to be called before this function. See also PDF_get_info, PDF_set_info_creator, PDF_set_info_author, PDF_set_info_title, PDF_set_info_subject. PDF_set_info_author Fills the author field of the info structure Description void pdf_set_info_author info info string author The PDF_set_info_author function sets the author of a pdf document. It has to be called after PDF_get_info and before PDF_open. Calling it after PDF_open will have no effect on the document. This function is not part of the pdf library. This function takes a different first parameter if pdflib 2.0 support is activated. The first parameter has to be the identifier of the pdf document as returned by pdf_open. Consequently, pdf_open has to be called before this function. See also PDF_get_info, PDF_set_info_creator, PDF_set_info_keywords, PDF_set_info_title, PDF_set_info_subject. PDF_open Opens a new pdf document Description int pdf_open int file int info The PDF_open function opens a new pdf document. The corresponding file has to be opened with fopen and the file descriptor passed as argument file. info is the info structure that has to be created with pdf_get_info. The info structure will be deleted within this function. The return value is needed as the first parameter in all other functions writing to the pdf document. This function does not allow the second parameter if pdflib 2.0 support is activated. See also fopen, PDF_get_info, PDF_close. PDF_close Closes a pdf document Description void pdf_close int pdf document The PDF_close function closes the pdf document. Due to an unclean implementation of the pdflib 0.6 the internal closing of the document also closes the file. This should not be done because pdflib did not open the file, but expects an already open file when PDF_open is called. Consequently it shouldn't close the file. In order to fix this just take out line 190 of the file p_basic.c in the pdflib 0.6 source distribution until the next release of pdflib will fix this. This function works properly without any patches to pdflib if pdflib 2.0 support is activated. See also PDF_open, fclose. PDF_begin_page Starts new page Description void pdf_begin_page int pdf document double height double width The PDF_begin_page function starts a new page with height height and width width. In order to create a valid document you must call this function and PDF_end_page. See also PDF_end_page. PDF_end_page Ends a page Description void pdf_end_page int pdf document The PDF_end_page function ends a page. Once a page is ended it cannot be modified anymore. See also PDF_begin_page. PDF_show Output text at current position Description void pdf_show int pdf document string text The PDF_show function outputs the string text at the current position using the current font. See also PDF_show_xy, PDF_set_text_pos, PDF_set_font. PDF_show_xy Output text at given position Description void pdf_show_xy int pdf document string text double x-koor double y-koor The PDF_show_xy function outputs the string text at position (x-koor, y-koor). See also PDF_show. PDF_set_font Selects a font face and size Description void pdf_set_font int pdf document string font name double size int encoding int embed The PDF_set_font function sets the current font face, font size and encoding. You will need to provide the Adobe Font Metrics (afm-files) for the font in the font path (default is ./fonts). The last parameter encoding can take the following values: 0 = builtin, 1 = pdfdoc, 2 = macroman, 3 = macexpert, 4 = winansi. An encoding greater than 4 and less than 0 will default to winansi. winansi is often a good choice. If the last parameter is set to 1 the font is embedded into the pdf document otherwise it is not. This function has to be called after PDF_begin_page in order to create a valid pdf document. This function does not need the afm files for winansi encoding if pdflib 2.0 support is activated. PDF_set_leading Sets distance between text lines Description void pdf_set leading int pdf document double distance The PDF_set_leading function sets the distance between text lines. This will be used if text is output by PDF_continue_text. See also PDF_continue_text. PDF_set_text_rendering Determines how text is rendered Description void pdf_set_text_rendering int pdf document int mode The PDF_set_text_rendering function determines how text is rendered. The possible values for mode are 0=fill text, 1=stroke text, 2=fill and stroke text, 3=invisible, 4=fill text and add it to cliping path, 5=stroke text and add it to clipping path, 6=fill and stroke text and add it to cliping path, 7=add it to clipping path. PDF_set_horiz_scaling Sets horizontal scaling of text Description void pdf_set_horiz_scaling int pdf document double scale The PDF_set_horiz_scaling function sets the horizontal scaling to scale percent. PDF_set_text_rise Sets the text rise Description void pdf_set_text_rise int pdf document double value The PDF_set_text_rise function sets the text rising to value points. PDF_set_text_matrix Sets the text matrix Description void pdf_set_text_matrix int pdf document array matrix The PDF_set_text_matrix function sets a matrix which describes a transformation applied on the current text font. The matrix has to passed as an array with six elements. PDF_set_text_pos Sets text position Description void pdf_set_text_pos int pdf document double x-koor double y-koor The PDF_set_text_pos function sets the position of text for the next pdf_show function call. See also PDF_show, PDF_show_xy. PDF_set_char_spacing Sets character spacing Description void pdf_set_char_spacing int pdf document double space The PDF_set_char_spacing function sets the spacing between characters. See also PDF_set_word_spacing, PDF_set_leading. PDF_set_word_spacing Sets spacing between words Description void pdf_set_word_spacing int pdf document double space The PDF_set_word_spacing function sets the spacing between words. See also PDF_set_char_spacing, PDF_set_leading. PDF_continue_text Outputs text in next line Description void pdf_continue_text int pdf document string text The PDF_continue_text function outputs the string in text in the next line. The distance between the lines can be set with PDF_set_leading. See also PDF_show_xy, PDF_set_leading, PDF_set_text_pos. PDF_stringwidth Returns width of text using current font Description double pdf_stringwidth int pdf document string text The PDF_stringwidth function returns the width of the string in text. It requires a font to be set before. See also PDF_set_font. PDF_save Saves the current environment Description void pdf_save int pdf document The PDF_save function saves the current environment. It works like the postscript command gsave. Very useful if you want to translate or rotate an object without effecting other objects. PDF_save should always be followed by PDF_restore. See also PDF_restore. PDF_restore Restores formerly saved environment Description void pdf_restore int pdf document The PDF_restore function restores the environment saved with PDF_save. It works like the postscript command grestore. Very useful if you want to translate or rotate an object without effecting other objects. Save and Restore <?php PDF_save($pdf); // do all kinds of rotations, transformations, ... PDF_restore($pdf) ?> See also PDF_save. PDF_translate Sets origin of coordinate system Description void pdf_translate int pdf document double x-koor double y-koor The PDF_translate function set the origin of coordinate system to the point (x-koor, y-koor). The following example draws a line from (0, 0) to (200, 200) relative to the initial coordinate system. You have to set the current point after PDF_translate and before you start drawing more objects. Translation <?php PDF_moveto($pdf, 0, 0); PDF_lineto($pdf, 100, 100); PDF_stroke($pdf); PDF_translate($pdf, 100, 100); PDF_moveto($pdf, 0, 0); PDF_lineto($pdf, 100, 100); PDF_stroke($pdf); ?> PDF_scale Sets scaling Description void pdf_scale int pdf document double x-scale double y-scale The PDF_scale function set the scaling factor in both directions. The following example scales x and y direction by 72. The following line will therefore be drawn one inch in both directions. Scaling <?php PDF_scale($pdf, 72.0, 72.0); PDF_lineto($pdf, 1, 1); PDF_stroke($pdf); ?> PDF_rotate Sets rotation Description void pdf_rotate int pdf document double angle The PDF_rotate function set the rotation in degress to angle. PDF_setflat Sets flatness Description void pdf_setflat int pdf document double value The PDF_setflat function set the flatness to a value between 0 and 100. PDF_setlinejoin Sets linejoin parameter Description void pdf_setlinejoin int pdf document long value The PDF_setlinejoin function set the linejoin parameter between a value of 0 and 2. PDF_setlinecap Sets linecap parameter Description void pdf_setlinecap int pdf document int value The PDF_setlinecap function set the linecap parameter between a value of 0 and 2. PDF_setmiterlimit Sets miter limit Description void pdf_setmiterlimit int pdf document double value The PDF_setmiterlimit function set the miter limit to a value greater of equal than 1. PDF_setlinewidth Sets line width Description void pdf_setlinewidth int pdf document double width The PDF_setlinewidth function set the line width to width. PDF_setdash Sets dash pattern Description void pdf_setdash int pdf document double white double black The PDF_setdash function set the dash pattern white white points and black black points. If both are 0 a solid line is set. PDF_moveto Sets current point Description void pdf_moveto int pdf document double x-koor double y-koor The PDF_moveto function set the current point to the coordinates x-koor and y-koor. PDF_curveto Draws a curve Description void pdf_curveto int pdf document double x1 double y1 double x2 double y2 double x3 double y3 The PDF_curveto function draws a Bezier curve from the current point to the point (x3, y3) using (x1, y1) and (x2, y2) as control points. See also PDF_moveto, PDF_lineto, PDF_stroke. PDF_lineto Draws a line Description void pdf_lineto int pdf document double x-koor double y-koor The PDF_lineto function draws a line from the current point to the point with coordinates (x-koor, y-koor). See also PDF_moveto, PDF_curveto, PDF_stroke. PDF_circle Draws a circle Description void pdf_circle int pdf document double x-koor double y-koor double radius The PDF_circle function draws a circle with center at point (x-koor, y-koor) and radius radius. See also PDF_arc, PDF_stroke. PDF_arc Draws an arc Description void pdf_arc int pdf document double x-koor double y-koor double radius double start double end The PDF_arc function draws an arc with center at point (x-koor, y-koor) and radius radius, starting at angle start and ending at angle end. See also PDF_circle, PDF_stroke. PDF_rect Draws a rectangle Description void pdf_rect int pdf document double x-koor double y-koor double width double height The PDF_rect function draws a rectangle with its lower left corner at point (x-koor, y-koor). This width is set to widgth. This height is set to height. See also PDF_stroke. PDF_closepath Closes path Description void pdf_closepath int pdf document The PDF_closepath function closes the current path. This means, it draws a line from current point to the point where the first line was started. Many functions like PDF_moveto, PDF_circle and PDF_rect start a new path. PDF_stroke Draws line along path Description void pdf_stroke int pdf document The PDF_stroke function draws a line along current path. The current path is the sum of all line drawing. Without this function the line would not be drawn. See also PDF_closepath, PDF_closepath_stroke. PDF_closepath_stroke Closes path and draws line along path Description void pdf_closepath_stroke int pdf document The PDF_closepath_stroke function is a combination of PDF_closepath and PDF_stroke. Than clears the path. See also PDF_closepath, PDF_stroke. PDF_fill Fills current path Description void pdf_fill int pdf document The PDF_fill function fills the interior of the current path with the current fill color. See also PDF_closepath, PDF_stroke, PDF_setgray_fill, PDF_setgray, PDF_setrgbcolor_fill, PDF_setrgbcolor. PDF_fill_stroke Fills and strokes current path Description void pdf_fill_stroke int pdf document The PDF_fill_stroke function fills the interior of the current path with the current fill color and draws current path. See also PDF_closepath, PDF_stroke, PDF_fill, PDF_setgray_fill, PDF_setgray, PDF_setrgbcolor_fill, PDF_setrgbcolor. PDF_closepath_fill_stroke Closes, fills and strokes current path Description void pdf_closepath_fill_stroke int pdf document The PDF_closepath_fill_stroke function closes, fills the interior of the current path with the current fill color and draws current path. See also PDF_closepath, PDF_stroke, PDF_fill, PDF_setgray_fill, PDF_setgray, PDF_setrgbcolor_fill, PDF_setrgbcolor. PDF_endpath Ends current path Description void pdf_endpath int pdf document The PDF_endpath function ends the current path but does not close it. See also PDF_closepath. PDF_clip Clips to current path Description void pdf_clip int pdf document The PDF_clip function clips all drawing to the current path. PDF_setgray_fill Sets filling color to gray value Description void pdf_setgray_fill int pdf document double value The PDF_setgray_fill function sets the current gray value to fill a path. See also PDF_setrgbcolor_fill. PDF_setgray_stroke Sets drawing color to gray value Description void pdf_setgray_stroke int pdf document double gray value The PDF_setgray_stroke function sets the current drawing color to the given gray value. See also PDF_setrgbcolor_stroke. PDF_setgray Sets drawing and filling color to gray value Description void pdf_setgray int pdf document double gray value The PDF_setgray_stroke function sets the current drawing and filling color to the given gray value. See also PDF_setrgbcolor_stroke, PDF_setrgbcolor_fill. PDF_setrgbcolor_fill Sets filling color to rgb color value Description void pdf_setrgbcolor_fill int pdf document double red value double green value double blue value The PDF_setrgbcolor_fill function sets the current rgb color value to fill a path. See also PDF_setrgbcolor_fill. PDF_setrgbcolor_stroke Sets drawing color to rgb color value Description void pdf_setrgbcolor_stroke int pdf document double red value double green value double blue value The PDF_setrgbcolor_stroke function sets the current drawing color to the given rgb color value. See also PDF_setrgbcolor_stroke. PDF_setrgbcolor Sets drawing and filling color to rgb color value Description void pdf_setrgbcolor int pdf document double red value double green value double blue value The PDF_setrgbcolor_stroke function sets the current drawing and filling color to the given rgb color value. See also PDF_setrgbcolor_stroke, PDF_setrgbcolor_fill. PDF_add_outline Adds bookmark for current page Description void pdf_add_outline int pdf document string text The PDF_add_outline function adds a bookmark with text text that points to the current page. Unfortunately pdflib does not make a copy of the string, which forces PHP to allocate the memory. Currently this piece of memory is not been freed by any PDF function but it will be taken care of by the PHP memory manager. PDF_set_transition Sets transition between pages Description void pdf_set_transition int pdf document int transition The PDF_set_transition function set the transition between following pages. The value of transition can be 0 for none, 1 for two lines sweeping across the screen reveal the page, 2 for multiple lines sweeping across the screen reveal the page, 3 for a box reveals the page, 4 for a single line sweeping across the screen reveals the page, 5 for the old page dissolves to reveal the page, 6 for the dissolve effect moves from one screen edge to another, 7 for the old page is simply replaced by the new page (default) See also PDF_set_duration. PDF_set_duration Sets duration between pages Description void pdf_set_duration int pdf document double duration The PDF_set_duration function set the duration between following pages in seconds. See also PDF_set_transition. PDF_open_gif Opens a GIF image Description int pdf_open_gif int pdf document string filename The PDF_open_gif function opens an image stored in the file with the name filename. The format of the image has to be gif. The function returns a pdf image identifier. Including a gif image <?php $im = PDF_open_gif($pdf, "test.gif"); pdf_place_image($pdf, $im, 100, 100, 1); pdf_close_image($pdf, $im); ?> See also PDF_close_image, PDF_open_jpeg, PDF_open_memory_image, PDF_execute_image, PDF_place_image, PDF_put_image. PDF_open_memory_image Opens an image created with PHP's image functions Description int pdf_open_memory_image int pdf document string int image The PDF_open_memory_image function takes an image created with the PHP's image functions and makes it available for the pdf document. The function returns a pdf image identifier. Including a memory image <?php $im = ImageCreate(100, 100); $col = ImageColorAllocate($im, 80, 45, 190); ImageFill($im, 10, 10, $col); $pim = PDF_open_memory_image($pdf, $im); ImageDestroy($im); pdf_place_image($pdf, $pim, 100, 100, 1); pdf_close_image($pdf, $pim); ?> See also PDF_close_image, PDF_open_jpeg, PDF_open_gif, PDF_execute_image, PDF_place_image, PDF_put_image. PDF_open_jpeg Opens a JPEG image Description int pdf_open_jpeg int pdf document string filename The PDF_open_jpeg function opens an image stored in the file with the name filename. The format of the image has to be jpeg. The function returns a pdf image identifier. See also PDF_close_image, PDF_open_gif, PDF_open_memory_image, PDF_execute_image, PDF_place_image, PDF_put_image. PDF_close_image Closes an image Description void pdf_close_image int image The PDF_close_image function closes an image which has been opened with any of the PDF_open_xxx functions. See also PDF_open_jpeg, PDF_open_gif, PDF_open_memory_image. PDF_place_image Places an image on the page Description void pdf_place_image int pdf document int image double x-koor double y-koor double scale The PDF_place_image function places an image on the page at postion (x-koor, x-koor). The image can be scaled at the same time. See also PDF_put_image. PDF_put_image Stores an image in the PDF for later use Description void pdf_put_image int pdf document int image The PDF_put_image function places an image in the PDF file without showing it. The stored image can be displayed with the PDF_execute_image function as many times as needed. This is useful when using the same image multiple times in order to keep the file size small. Using PDF_put_image and PDF_execute_image is highly recommended for larger images (several kb) if they show up more than once in the document. This function has become meaningless with version 2.01 of pdflib. It will just output a warning. See also PDF_put_image, PDF_place_image, PDF_execute_image. PDF_execute_image Places a stored image on the page Description void pdf_execute_image int pdf document int image double x-coor double y-coor double scale The PDF_execute_image function displays an image that has been put in the PDF file with the PDF_put_image function on the current page at the given coordinates. The image can be scaled while displaying it. A scale of 1.0 will show the image in the original size. This function has become meaningless with version 2.01 of pdflib. It will just output a warning. Multiple show of an image <?php $im = ImageCreate(100, 100); $col1 = ImageColorAllocate($im, 80, 45, 190); ImageFill($im, 10, 10, $col1); $pim = PDF_open_memory_image($pdf, $im); pdf_put_image($pdf, $pim); pdf_execute_image($pdf, $pim, 100, 100, 1); pdf_execute_image($pdf, $pim, 200, 200, 2); pdf_close_image($pdf, $pim); ?> pdf_add_annotation Adds annotation Description void pdf_add_annotation int pdf document double llx double lly double urx double ury string title string content The pdf_add_annotation adds a note with the lower left corner at (llx, lly) and the upper right corner at (urx, ury).