Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > media > main-release > by-pkgid > ebb1914cf182a88528b4547490db1dd8 > files > 1635

kdewebdev-quanta-doc-3.5.9-2mdv2008.1.x86_64.rpm

<HTML
><HEAD
><TITLE
>ClibPDF functions</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.44"><LINK
REL="HOME"
TITLE="PHP Manual"
HREF="manual.html"><LINK
REL="UP"
TITLE="Function Reference"
HREF="funcref.html"><LINK
REL="PREVIOUS"
TITLE="easter_days"
HREF="function.easter-days.html"><LINK
REL="NEXT"
TITLE="cpdf_global_set_document_limits"
HREF="function.cpdf-global-set-document-limits.html"></HEAD
><BODY
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.easter-days.html"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.cpdf-global-set-document-limits.html"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="reference"
><A
NAME="ref.cpdf"
></A
><DIV
CLASS="TITLEPAGE"
><H1
CLASS="title"
>VI. ClibPDF functions</H1
><DIV
CLASS="PARTINTRO"
><A
NAME="AEN4850"
></A
><P
>&#13;    ClibPDF lets you create PDF documents with PHP. It is available at
    <A
HREF="http://www.fastio.com"
TARGET="_top"
>FastIO</A
> but it isn't free
    software. You should definitely read the licence before you start
    playing with ClibPDF. If you cannot fullfil the licence agreement
    consider using pdflib by Thomas Merz, which is also very powerful.
    ClibPDF functionality and API is similar to Thomas Merz's pdflib but,
    according to FastIO, ClibPDF is faster and creates smaller documents.
    This may have changed with the new version 2.0 of pdflib.  A simple
    benchmark (the pdfclock.c example from pdflib 2.0 turned into a php
    script) actually shows no difference in speed at all. The file size
    is also similar if compression is turned off.  So, try them both
    and see which one does the job for you.</P
><P
>&#13;    This documentation should be read alongside the ClibPDF manual since it
    explains the library in much greater detail. 
    </P
><P
>&#13;    Many functions in the native ClibPDF and the PHP module, as
    well as in pdflib, have the same name.  All functions except for
    <A
HREF="function.cpdf-open.html"
><B
CLASS="function"
>cpdf_open()</B
></A
> take the handle for the document as
    their first parameter.
    Currently this handle is not used internally since ClibPDF does
    not support the creation of several PDF documents at the same time.
    Actually, you should not even try it, the results are unpredictable. I
    can't oversee what the consequences in a multi threaded environment
    are.  According to the author of ClibPDF this will change in one of
    the next releases (current version when this was written is 1.10).
    If you need this functionality use the pdflib module.</P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Note: </B
>
    The function <A
HREF="function.cpdf-set-font.html"
><B
CLASS="function"
>cpdf_set_font()</B
></A
> has changed since PHP3
    to support asian fonts. The encoding parameter is no longer an integer
    but a string.</P
></BLOCKQUOTE
></DIV
><P
>&#13;    One big advantage of ClibPDF over pdflib is the possibility to create
    the pdf document completely in memory without using temporary files.
    It also provides the ability to pass coordinates in a predefined
    unit length. This is a handy feature but can be simulated with
    <A
HREF="function.pdf-translate.html"
><B
CLASS="function"
>pdf_translate()</B
></A
>.</P
><P
>&#13;    Most of the functions are fairly easy to use. The most difficult part
    is probably creating a very simple PDF document at all. The following
    example should help you get started. It creates a document
    with one page. The page contains the text "Times-Roman" in an
    outlined 30pt font. The text is underlined.</P
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><P
><B
>Example 1. Simple ClibPDF Example</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>  1&nbsp;
  2&nbsp;&#60;?php
  3&nbsp;$cpdf = cpdf_open(0);
  4&nbsp;cpdf_page_init($cpdf, 1, 0, 595, 842);
  5&nbsp;cpdf_add_outline($cpdf, 0, 0, 0, 1, "Page 1");
  6&nbsp;cpdf_set_font($cpdf, "Times-Roman", 30, "WinAnsiEncoding");
  7&nbsp;cpdf_set_text_rendering($cpdf, 1);
  8&nbsp;cpdf_text($cpdf, "Times Roman outlined", 50, 750);
  9&nbsp;cpdf_moveto($cpdf, 50, 740);
 10&nbsp;cpdf_lineto($cpdf, 330, 740);
 11&nbsp;cpdf_stroke($cpdf);
 12&nbsp;cpdf_finalize($cpdf);
 13&nbsp;Header("Content-type: application/pdf");
 14&nbsp;cpdf_output_buffer($cpdf);
 15&nbsp;cpdf_close($cpdf);
 16&nbsp;?&#62;
 17&nbsp;    </PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
><P
>&#13;  The pdflib distribution contains a more complex example which creates a
  series of pages with an analog clock. Here is that example converted
  into PHP using the ClibPDF extension:</P
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><P
><B
>Example 2. pdfclock example from pdflib 2.0 distribution</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>  1&nbsp;
  2&nbsp;&#60;?php
  3&nbsp;$radius = 200;
  4&nbsp;$margin = 20;
  5&nbsp;$pagecount = 40;
  6&nbsp;
  7&nbsp;$pdf = cpdf_open(0);
  8&nbsp;cpdf_set_creator($pdf, "pdf_clock.php3");
  9&nbsp;cpdf_set_title($pdf, "Analog Clock");
 10&nbsp;  
 11&nbsp;while($pagecount-- &#62; 0) {
 12&nbsp;  cpdf_page_init($pdf, $pagecount+1, 0, 2 * ($radius + $margin), 2 * ($radius + $margin), 1.0);
 13&nbsp;  
 14&nbsp;  cpdf_set_page_animation($pdf, 4, 0.5, 0, 0, 0);  /* wipe */
 15&nbsp;  
 16&nbsp;  cpdf_translate($pdf, $radius + $margin, $radius + $margin);
 17&nbsp;  cpdf_save($pdf);
 18&nbsp;  cpdf_setrgbcolor($pdf, 0.0, 0.0, 1.0);
 19&nbsp;  
 20&nbsp;  /* minute strokes */
 21&nbsp;  cpdf_setlinewidth($pdf, 2.0);
 22&nbsp;  for ($alpha = 0; $alpha &#60; 360; $alpha += 6)
 23&nbsp;    {
 24&nbsp;    cpdf_rotate($pdf, 6.0);
 25&nbsp;    cpdf_moveto($pdf, $radius, 0.0);
 26&nbsp;    cpdf_lineto($pdf, $radius-$margin/3, 0.0);
 27&nbsp;    cpdf_stroke($pdf);
 28&nbsp;    }
 29&nbsp;  
 30&nbsp;  cpdf_restore($pdf);
 31&nbsp;  cpdf_save($pdf);
 32&nbsp; 
 33&nbsp;  /* 5 minute strokes */
 34&nbsp;  cpdf_setlinewidth($pdf, 3.0);
 35&nbsp;  for ($alpha = 0; $alpha &#60; 360; $alpha += 30)
 36&nbsp;  {
 37&nbsp;    cpdf_rotate($pdf, 30.0);
 38&nbsp;    cpdf_moveto($pdf, $radius, 0.0);
 39&nbsp;    cpdf_lineto($pdf, $radius-$margin, 0.0);
 40&nbsp;    cpdf_stroke($pdf);
 41&nbsp;  }
 42&nbsp;
 43&nbsp;  $ltime = getdate();
 44&nbsp;
 45&nbsp;  /* draw hour hand */
 46&nbsp;  cpdf_save($pdf);
 47&nbsp;  cpdf_rotate($pdf, -(($ltime['minutes']/60.0) + $ltime['hours'] - 3.0) * 30.0);
 48&nbsp;  cpdf_moveto($pdf, -$radius/10, -$radius/20);
 49&nbsp;  cpdf_lineto($pdf, $radius/2, 0.0);
 50&nbsp;  cpdf_lineto($pdf, -$radius/10, $radius/20);
 51&nbsp;  cpdf_closepath($pdf);
 52&nbsp;  cpdf_fill($pdf);
 53&nbsp;  cpdf_restore($pdf);
 54&nbsp;
 55&nbsp;  /* draw minute hand */
 56&nbsp;  cpdf_save($pdf);
 57&nbsp;  cpdf_rotate($pdf, -(($ltime['seconds']/60.0) + $ltime['minutes'] - 15.0) * 6.0);
 58&nbsp;  cpdf_moveto($pdf, -$radius/10, -$radius/20);
 59&nbsp;  cpdf_lineto($pdf, $radius * 0.8, 0.0);
 60&nbsp;  cpdf_lineto($pdf, -$radius/10, $radius/20);
 61&nbsp;  cpdf_closepath($pdf);
 62&nbsp;  cpdf_fill($pdf);
 63&nbsp;  cpdf_restore($pdf);
 64&nbsp;
 65&nbsp;  /* draw second hand */
 66&nbsp;  cpdf_setrgbcolor($pdf, 1.0, 0.0, 0.0);
 67&nbsp;  cpdf_setlinewidth($pdf, 2);
 68&nbsp;  cpdf_save($pdf);
 69&nbsp;  cpdf_rotate($pdf, -(($ltime['seconds'] - 15.0) * 6.0));
 70&nbsp;  cpdf_moveto($pdf, -$radius/5, 0.0);
 71&nbsp;  cpdf_lineto($pdf, $radius, 0.0);
 72&nbsp;  cpdf_stroke($pdf);
 73&nbsp;  cpdf_restore($pdf);
 74&nbsp;
 75&nbsp;  /* draw little circle at center */
 76&nbsp;  cpdf_circle($pdf, 0, 0, $radius/30);
 77&nbsp;  cpdf_fill($pdf);
 78&nbsp;
 79&nbsp;  cpdf_restore($pdf);
 80&nbsp;
 81&nbsp;  cpdf_finalize_page($pdf, $pagecount+1);
 82&nbsp;}
 83&nbsp;
 84&nbsp;cpdf_finalize($pdf);
 85&nbsp;Header("Content-type: application/pdf");
 86&nbsp;cpdf_output_buffer($pdf);
 87&nbsp;cpdf_close($pdf);
 88&nbsp;?&#62;
 89&nbsp;    </PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="TOC"
><DL
><DT
><B
>Table of Contents</B
></DT
><DT
><A
HREF="function.cpdf-global-set-document-limits.html"
>cpdf_global_set_document_limits</A
> &#8212; Sets document limits for any pdf document</DT
><DT
><A
HREF="function.cpdf-set-creator.html"
>cpdf_set_creator</A
> &#8212; Sets the creator field in the pdf document</DT
><DT
><A
HREF="function.cpdf-set-title.html"
>cpdf_set_title</A
> &#8212; Sets the title field of the pdf document</DT
><DT
><A
HREF="function.cpdf-set-subject.html"
>cpdf_set_subject</A
> &#8212; Sets the subject field of the pdf document</DT
><DT
><A
HREF="function.cpdf-set-keywords.html"
>cpdf_set_keywords</A
> &#8212; Sets the keywords field of the pdf document</DT
><DT
><A
HREF="function.cpdf-open.html"
>cpdf_open</A
> &#8212; Opens a new pdf document</DT
><DT
><A
HREF="function.cpdf-close.html"
>cpdf_close</A
> &#8212; Closes the pdf document</DT
><DT
><A
HREF="function.cpdf-page-init.html"
>cpdf_page_init</A
> &#8212; Starts new page</DT
><DT
><A
HREF="function.cpdf-finalize-page.html"
>cpdf_finalize_page</A
> &#8212; Ends page</DT
><DT
><A
HREF="function.cpdf-finalize.html"
>cpdf_finalize</A
> &#8212; Ends document</DT
><DT
><A
HREF="function.cpdf-output-buffer.html"
>cpdf_output_buffer</A
> &#8212; Outputs the pdf document in memory buffer</DT
><DT
><A
HREF="function.cpdf-save-to-file.html"
>cpdf_save_to_file</A
> &#8212; Writes the pdf document into a file</DT
><DT
><A
HREF="function.cpdf-set-current-page.html"
>cpdf_set_current_page</A
> &#8212; Sets current page</DT
><DT
><A
HREF="function.cpdf-begin-text.html"
>cpdf_begin_text</A
> &#8212; Starts text section</DT
><DT
><A
HREF="function.cpdf-end-text.html"
>cpdf_end_text</A
> &#8212; Ends text section</DT
><DT
><A
HREF="function.cpdf-show.html"
>cpdf_show</A
> &#8212; Output text at current position</DT
><DT
><A
HREF="function.cpdf-show-xy.html"
>cpdf_show_xy</A
> &#8212; Output text at position</DT
><DT
><A
HREF="function.cpdf-text.html"
>cpdf_text</A
> &#8212; Output text with parameters</DT
><DT
><A
HREF="function.cpdf-set-font.html"
>cpdf_set_font</A
> &#8212; Select the current font face and size</DT
><DT
><A
HREF="function.cpdf-set-leading.html"
>cpdf_set_leading</A
> &#8212; Sets distance between text lines</DT
><DT
><A
HREF="function.cpdf-set-text-rendering.html"
>cpdf_set_text_rendering</A
> &#8212; Determines how text is rendered</DT
><DT
><A
HREF="function.cpdf-set-horiz-scaling.html"
>cpdf_set_horiz_scaling</A
> &#8212; Sets horizontal scaling of text</DT
><DT
><A
HREF="function.cpdf-set-text-rise.html"
>cpdf_set_text_rise</A
> &#8212; Sets the text rise</DT
><DT
><A
HREF="function.cpdf-set-text-matrix.html"
>cpdf_set_text_matrix</A
> &#8212; Sets the text matrix</DT
><DT
><A
HREF="function.cpdf-set-text-pos.html"
>cpdf_set_text_pos</A
> &#8212; Sets text position</DT
><DT
><A
HREF="function.cpdf-set-char-spacing.html"
>cpdf_set_char_spacing</A
> &#8212; Sets character spacing</DT
><DT
><A
HREF="function.cpdf-set-word-spacing.html"
>cpdf_set_word_spacing</A
> &#8212; Sets spacing between words</DT
><DT
><A
HREF="function.cpdf-continue-text.html"
>cpdf_continue_text</A
> &#8212; Output text in next line</DT
><DT
><A
HREF="function.cpdf-stringwidth.html"
>cpdf_stringwidth</A
> &#8212; Returns width of text in current font</DT
><DT
><A
HREF="function.cpdf-save.html"
>cpdf_save</A
> &#8212; Saves current enviroment</DT
><DT
><A
HREF="function.cpdf-restore.html"
>cpdf_restore</A
> &#8212; Restores formerly saved enviroment</DT
><DT
><A
HREF="function.cpdf-translate.html"
>cpdf_translate</A
> &#8212; Sets origin of coordinate system</DT
><DT
><A
HREF="function.cpdf-scale.html"
>cpdf_scale</A
> &#8212; Sets scaling</DT
><DT
><A
HREF="function.cpdf-rotate.html"
>cpdf_rotate</A
> &#8212; Sets rotation</DT
><DT
><A
HREF="function.cpdf-setflat.html"
>cpdf_setflat</A
> &#8212; Sets flatness</DT
><DT
><A
HREF="function.cpdf-setlinejoin.html"
>cpdf_setlinejoin</A
> &#8212; Sets linejoin parameter</DT
><DT
><A
HREF="function.cpdf-setlinecap.html"
>cpdf_setlinecap</A
> &#8212; Sets linecap aparameter</DT
><DT
><A
HREF="function.cpdf-setmiterlimit.html"
>cpdf_setmiterlimit</A
> &#8212; Sets miter limit</DT
><DT
><A
HREF="function.cpdf-setlinewidth.html"
>cpdf_setlinewidth</A
> &#8212; Sets line width</DT
><DT
><A
HREF="function.cpdf-setdash.html"
>cpdf_setdash</A
> &#8212; Sets dash pattern</DT
><DT
><A
HREF="function.cpdf-moveto.html"
>cpdf_moveto</A
> &#8212; Sets current point</DT
><DT
><A
HREF="function.cpdf-rmoveto.html"
>cpdf_rmoveto</A
> &#8212; Sets current point</DT
><DT
><A
HREF="function.cpdf-curveto.html"
>cpdf_curveto</A
> &#8212; Draws a curve</DT
><DT
><A
HREF="function.cpdf-lineto.html"
>cpdf_lineto</A
> &#8212; Draws a line</DT
><DT
><A
HREF="function.cpdf-rlineto.html"
>cpdf_rlineto</A
> &#8212; Draws a line</DT
><DT
><A
HREF="function.cpdf-circle.html"
>cpdf_circle</A
> &#8212; Draw a circle</DT
><DT
><A
HREF="function.cpdf-arc.html"
>cpdf_arc</A
> &#8212; Draws an arc</DT
><DT
><A
HREF="function.cpdf-rect.html"
>cpdf_rect</A
> &#8212; Draw a rectangle</DT
><DT
><A
HREF="function.cpdf-closepath.html"
>cpdf_closepath</A
> &#8212; Close path</DT
><DT
><A
HREF="function.cpdf-stroke.html"
>cpdf_stroke</A
> &#8212; Draw line along path</DT
><DT
><A
HREF="function.cpdf-closepath-stroke.html"
>cpdf_closepath_stroke</A
> &#8212; Close path and draw line along path</DT
><DT
><A
HREF="function.cpdf-fill.html"
>cpdf_fill</A
> &#8212; Fill current path</DT
><DT
><A
HREF="function.cpdf-fill-stroke.html"
>cpdf_fill_stroke</A
> &#8212; Fill and stroke current path</DT
><DT
><A
HREF="function.cpdf-closepath-fill-stroke.html"
>cpdf_closepath_fill_stroke</A
> &#8212; Close, fill and stroke current path</DT
><DT
><A
HREF="function.cpdf-clip.html"
>cpdf_clip</A
> &#8212; Clips to current path</DT
><DT
><A
HREF="function.cpdf-setgray-fill.html"
>cpdf_setgray_fill</A
> &#8212; Sets filling color to gray value</DT
><DT
><A
HREF="function.cpdf-setgray-stroke.html"
>cpdf_setgray_stroke</A
> &#8212; Sets drawing color to gray value</DT
><DT
><A
HREF="function.cpdf-setgray.html"
>cpdf_setgray</A
> &#8212; Sets drawing and filling color to gray value</DT
><DT
><A
HREF="function.cpdf-setrgbcolor-fill.html"
>cpdf_setrgbcolor_fill</A
> &#8212; Sets filling color to rgb color value</DT
><DT
><A
HREF="function.cpdf-setrgbcolor-stroke.html"
>cpdf_setrgbcolor_stroke</A
> &#8212; Sets drawing color to rgb color value</DT
><DT
><A
HREF="function.cpdf-setrgbcolor.html"
>cpdf_setrgbcolor</A
> &#8212; Sets drawing and filling color to rgb color value</DT
><DT
><A
HREF="function.cpdf-add-outline.html"
>cpdf_add_outline</A
> &#8212; Adds bookmark for current page</DT
><DT
><A
HREF="function.cpdf-set-page-animation.html"
>cpdf_set_page_animation</A
> &#8212; Sets duration between pages</DT
><DT
><A
HREF="function.cpdf-import-jpeg.html"
>cpdf_import_jpeg</A
> &#8212; Opens a JPEG image</DT
><DT
><A
HREF="function.cpdf-place-inline-image.html"
>cpdf_place_inline_image</A
> &#8212; Places an image on the page</DT
><DT
><A
HREF="function.cpdf-add-annotation.html"
>cpdf_add_annotation</A
> &#8212; Adds annotation</DT
></DL
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.easter-days.html"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="manual.html"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.cpdf-global-set-document-limits.html"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>easter_days</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="funcref.html"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>cpdf_global_set_document_limits</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>