{oapdf_gg}
Office software is closely linked to the PDF,the PDF is also must have to control!      Set home Page  Add to Favorites  
You are here:Home > PDF Application > PDF Development
PDF Development
PHP in the preparation of PDF document generator method tutorial
Finishing by: Date:2009-04-17 21:09:08 Popularity: Tags:

In addition to the PDF document where the image existing outside draw, PDF module also provides a number of functions to enable us to draw geometric shapes. For example: a straight line, round, rectangular and other geometric patterns, following a straight line is drawn for some of the implementation:

$ pdf = PDF_new ();
PDF_open_file ($ pdf, "LineExam.pdf");
PDF_begin_page ($ pdf, 595, 842);
$ arial = PDF_findfont ($ pdf, "Arial", "host", 1);
PDF_setfont ($ pdf, $ arial, 12);

//set line color
PDF_setcolor ($ pdf, "stroke", "rgb", 0, 0, 0);

//placed in the upper left corner of a Logo logo
$ image = PDF_open_image_file ($ pdf, "jpeg", "logo.jpg");
PDF_place_image ($ pdf, $ image, 50, 785, 0.5);

//in the Logo to draw a straight line under the logo
PDF_moveto ($ pdf, 20, 780);
PDF_lineto ($ pdf, 575, 780);
PDF_stroke ($ pdf);

//in the bottom of the page to draw a straight line another
PDF_moveto ($ pdf, 20,50);
PDF_lineto ($ pdf, 575, 50);
PDF_stroke ($ pdf);

//output some text
PDF_show_xy ($ pdf, "Meng's Corporation", 200, 35);
PDF_end_page ($ pdf);
PDF_close ($ pdf);
?>

from the above example can be seen, it is necessary to draw a straight line can function only need three: PDF_moveto (), PDF_lineto () and PDF_stroke (). The above example is the first PDF_moveto ($ pdf, 20, 780) function to move the cursor to coordinates (20,780), then PDF_lineto ($ pdf, 575, 780) the definition of linear function of the coordinates of a point (575, 780), and finally with PDF_stroke ($ pdf) painting round. A function of the color settings PDF_setcolor ($ pdf, "stroke", "rgb", 0, 0, 0) There are several parameters, including the color-filled pattern of stroke, fill, both the three options, colors, or RGB can be CMYK color value color scheme. It is worth noting that: PDF_setcolor () function used in the percentage of value is the color, that is the brightness of the color, such as: If you want to set to red (RGB: 255,0,0), you can write: PDF_setcolor ($ pdf, "stroke", "rgb", 1, 0, 0), yellow if you want to set, it can be: PDF_setcolor ($ pdf, "stroke", "rgb", 1, 1, 0).

to paint with color-filled rectangular and circular, you can use the following methods:

//set the fill color
PDF_setcolor ($ pdf, "fill", "rgb", 1, 1, 0);

//set the border line color
PDF_setcolor ($ pdf, "stroke", "rgb", 0, 0, 0);

//draw rectangle, behind the lower-left corner of the four parameters are the coordinates of X, Y and width, height
PDF_rect ($ pdf, 50, 500, 200, 300);
PDF_fill_stroke ($ pdf);
PDF_setcolor ($ pdf, "fill", "rgb", 0, 1, 0);
PDF_setcolor ($ pdf, "stroke", "rgb", 0, 0, 1);

//draw circle, the parameters are the center coordinates and radius of a circle
PDF_circle ($ pdf, 400, 600, 100)

In addition, PDFLib written document also provides summary information of the function, the function PDF_set_info_ * () at the beginning, this information may include: documentation of the author, title, content, theme and so on. Here are a few commonly used functions:

PDF_set_info_author ($ pdf, "net_lover");
PDF_set_info_creator ($ pdf, "Meng Xianhui");
PDF_set_info_title ($ pdf, "PHP Exam");
PDF_set_info_subject ($ pdf, "PHP");
PDF_set_info_keywords ($ pdf, "PHP PDF PDFLib ");

when using Acrobat Reader to open this document, the menu "File" - "Document Properties" - "Abstract" and will be able to see the information written into.
Having said that, I believe we PDFLib on how to create PDF documents using a basic understanding of it. Next, we will as a practical example to see how our services work. This example is based on data provided to generate the pie chart, first of all, the establishment of a data entry form, enter the pie chart in the size of each piece. The following documents:






pie chart

Generator









Please enter a pie chart for each data value to (,) separated:


there isArticle InformationsComment Information
Category column

Site Help | Site Map | Feedback |
OAPDF.COM Copyright 2009 V1.1