PDF functionsPDF
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_infoReturns an empty info structure for a pdf documentDescriptioninfo pdf_get_infostring 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_creatorFills the creator field of the info structureDescriptionvoid pdf_set_info_creatorinfo infostring 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_titleFills the title field of the info structureDescriptionvoid pdf_set_info_titleinfo infostring 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_subjectFills the subject field of the info structureDescriptionvoid pdf_set_info_subjectinfo infostring 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_keywordsFills the keywords field of the info structureDescriptionvoid pdf_set_info_keywordsinfo infostring 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_authorFills the author field of the info structureDescriptionvoid pdf_set_info_authorinfo infostring 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_openOpens a new pdf documentDescriptionint pdf_openint fileint 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_closeCloses a pdf documentDescriptionvoid pdf_closeint 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_pageStarts new pageDescriptionvoid pdf_begin_pageint pdf documentdouble heightdouble 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_pageEnds a pageDescriptionvoid pdf_end_pageint 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_showOutput text at current positionDescriptionvoid pdf_showint pdf documentstring 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_xyOutput text at given positionDescriptionvoid pdf_show_xyint pdf documentstring textdouble x-koordouble y-koor
The PDF_show_xy function outputs the
string text at position
(x-koor, y-koor).
See also PDF_show.PDF_set_fontSelects a font face and sizeDescriptionvoid pdf_set_fontint pdf documentstring font namedouble sizeint encodingint 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_leadingSets distance between text linesDescriptionvoid pdf_set leadingint pdf documentdouble 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_renderingDetermines how text is renderedDescriptionvoid pdf_set_text_renderingint pdf documentint 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_scalingSets horizontal scaling of textDescriptionvoid pdf_set_horiz_scalingint pdf documentdouble scale
The PDF_set_horiz_scaling function sets the
horizontal scaling to scale percent.PDF_set_text_riseSets the text riseDescriptionvoid pdf_set_text_riseint pdf documentdouble value
The PDF_set_text_rise function sets the
text rising to value points.PDF_set_text_matrixSets the text matrixDescriptionvoid pdf_set_text_matrixint pdf documentarray 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_posSets text positionDescriptionvoid pdf_set_text_posint pdf documentdouble x-koordouble 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_spacingSets character spacingDescriptionvoid pdf_set_char_spacingint pdf documentdouble space
The PDF_set_char_spacing function sets the
spacing between characters.
See also PDF_set_word_spacing,
PDF_set_leading.PDF_set_word_spacingSets spacing between wordsDescriptionvoid pdf_set_word_spacingint pdf documentdouble space
The PDF_set_word_spacing function sets the
spacing between words.
See also PDF_set_char_spacing,
PDF_set_leading.PDF_continue_textOutputs text in next lineDescriptionvoid pdf_continue_textint pdf documentstring 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_stringwidthReturns width of text using current fontDescriptiondouble pdf_stringwidthint pdf documentstring 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_saveSaves the current environmentDescriptionvoid pdf_saveint 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_restoreRestores formerly saved environmentDescriptionvoid pdf_restoreint 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_translateSets origin of coordinate systemDescriptionvoid pdf_translateint pdf documentdouble x-koordouble 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_scaleSets scalingDescriptionvoid pdf_scaleint pdf documentdouble x-scaledouble 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_rotateSets rotationDescriptionvoid pdf_rotateint pdf documentdouble angle
The PDF_rotate function set the rotation in
degress to angle.PDF_setflatSets flatnessDescriptionvoid pdf_setflatint pdf documentdouble value
The PDF_setflat function set the flatness to
a value between 0 and 100.PDF_setlinejoinSets linejoin parameterDescriptionvoid pdf_setlinejoinint pdf documentlong value
The PDF_setlinejoin function set the linejoin
parameter between a value of 0 and 2.PDF_setlinecapSets linecap parameterDescriptionvoid pdf_setlinecapint pdf documentint value
The PDF_setlinecap function set the linecap
parameter between a value of 0 and 2.PDF_setmiterlimitSets miter limitDescriptionvoid pdf_setmiterlimitint pdf documentdouble value
The PDF_setmiterlimit function set the miter limit
to a value greater of equal than 1.PDF_setlinewidthSets line widthDescriptionvoid pdf_setlinewidthint pdf documentdouble width
The PDF_setlinewidth function set the line width
to width.PDF_setdashSets dash patternDescriptionvoid pdf_setdashint pdf documentdouble whitedouble 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_movetoSets current pointDescriptionvoid pdf_movetoint pdf documentdouble x-koordouble y-koor
The PDF_moveto function set the current point
to the coordinates x-koor and
y-koor.PDF_curvetoDraws a curveDescriptionvoid pdf_curvetoint pdf documentdouble x1double y1double x2double y2double x3double 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_linetoDraws a lineDescriptionvoid pdf_linetoint pdf documentdouble x-koordouble 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_circleDraws a circleDescriptionvoid pdf_circleint pdf documentdouble x-koordouble y-koordouble 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_arcDraws an arcDescriptionvoid pdf_arcint pdf documentdouble x-koordouble y-koordouble radiusdouble startdouble 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_rectDraws a rectangleDescriptionvoid pdf_rectint pdf documentdouble x-koordouble y-koordouble widthdouble 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_closepathCloses pathDescriptionvoid pdf_closepathint 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_strokeDraws line along pathDescriptionvoid pdf_strokeint 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_strokeCloses path and draws line along pathDescriptionvoid pdf_closepath_strokeint 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_fillFills current pathDescriptionvoid pdf_fillint 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_strokeFills and strokes current pathDescriptionvoid pdf_fill_strokeint 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_strokeCloses, fills and strokes current pathDescriptionvoid pdf_closepath_fill_strokeint 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_endpathEnds current pathDescriptionvoid pdf_endpathint pdf document
The PDF_endpath function ends
the current path but does not close it.
See also PDF_closepath.PDF_clipClips to current pathDescriptionvoid pdf_clipint pdf document
The PDF_clip function clips all drawing
to the current path.PDF_setgray_fillSets filling color to gray valueDescriptionvoid pdf_setgray_fillint pdf documentdouble value
The PDF_setgray_fill function sets the current
gray value to fill a path.
See also PDF_setrgbcolor_fill.PDF_setgray_strokeSets drawing color to gray valueDescriptionvoid pdf_setgray_strokeint pdf documentdouble gray value
The PDF_setgray_stroke function sets the current
drawing color to the given gray value.
See also PDF_setrgbcolor_stroke.PDF_setgraySets drawing and filling color to gray valueDescriptionvoid pdf_setgrayint pdf documentdouble 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_fillSets filling color to rgb color valueDescriptionvoid pdf_setrgbcolor_fillint pdf documentdouble red valuedouble green valuedouble blue value
The PDF_setrgbcolor_fill function sets the current
rgb color value to fill a path.
See also PDF_setrgbcolor_fill.PDF_setrgbcolor_strokeSets drawing color to rgb color valueDescriptionvoid pdf_setrgbcolor_strokeint pdf documentdouble red valuedouble green valuedouble blue value
The PDF_setrgbcolor_stroke function sets the current
drawing color to the given rgb color value.
See also PDF_setrgbcolor_stroke.PDF_setrgbcolorSets drawing and filling color to rgb color valueDescriptionvoid pdf_setrgbcolorint pdf documentdouble red valuedouble green valuedouble 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_outlineAdds bookmark for current pageDescriptionvoid pdf_add_outlineint pdf documentstring 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_transitionSets transition between pagesDescriptionvoid pdf_set_transitionint pdf documentint 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_durationSets duration between pagesDescriptionvoid pdf_set_durationint pdf documentdouble duration
The PDF_set_duration function set the duration
between following pages in seconds.
See also PDF_set_transition.PDF_open_gifOpens a GIF imageDescriptionint pdf_open_gifint pdf documentstring 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_imageOpens an image created with PHP's image functionsDescriptionint pdf_open_memory_imageint pdf documentstring 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_jpegOpens a JPEG imageDescriptionint pdf_open_jpegint pdf documentstring 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_imageCloses an imageDescriptionvoid pdf_close_imageint 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_imagePlaces an image on the pageDescriptionvoid pdf_place_imageint pdf documentint imagedouble x-koordouble y-koordouble 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_imageStores an image in the PDF for later useDescriptionvoid pdf_put_imageint pdf documentint 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_imagePlaces a stored image on the pageDescriptionvoid pdf_execute_imageint pdf documentint imagedouble x-coordouble y-coordouble 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_annotationAdds annotationDescriptionvoid pdf_add_annotationint pdf documentdouble llxdouble llydouble urxdouble urystring titlestring content
The pdf_add_annotation adds a note with
the lower left corner at (llx,
lly) and the upper right corner at
(urx, ury).