Source code for file access. This section mainly describes php Tutorial file operations and xml document instance methods.
<? Php
// Create a new pdf document handle
$ Pdf = cpdf_open (0 );
// Open a file
Cpdf_open_file ($ pdf );
// Start a new page (a4)
Cpdf_begin_page ($ pdf, 595,842 );
// Obtain and use the font object
$ Arial = cpdf_findfont ($ pdf, "arial", "host", 1 );
Cpdf_setfont ($ pdf, $ arial, 10 );
// Output text
C1__show_xy ($ pdf, "this is an exam of pdf documents, it is a good lib,", 50,750 );
Cpdf_show_xy ($ pdf, "if you like, please try yourself! ", 50,730 );
// End page
Cpdf_end_page ($ pdf );
// Close and save the file
C__close ($ pdf );
// If you want to directly output the data to the client, add the following code
$ Buf = cpai_get_buffer ($ pdf );
$ Len = strlen ($ buf );
Header ("content-type: application/pdf ");
Header ("content-length: $ len ");
Header ("content-disposition: inline; filename=pie_php ");
Print $ buf;
C1__delete ($ pdf );
?>
Xml file
<? Php
$ Dom = new domdocument ();
$ Dom-> load ("order. xsl ");
$ Proc = new effectprocessor;
$ Xsl = $ proc-> importstylesheet ($ dom );
$ Xml = new domdocument ();
$ Xml-> load ('order. XML ');
$ String = $ proc-> transformtoxml ($ xml );
Echo $ string;
?>
Order. sls
<? Xml version = "1.0" encoding = 'gb2312 '?>
<Xsl: stylesheet version = "1.0" xmlns: xsl = "http://www.w3.org/1999/XSL/Transform">
<Xsl: output encoding = 'gb2312 '/>
<Xsl: param name = "column" select = "'sku '"/>
<Xsl: param name = "order" select = "'cending'"/>
<Xsl: template match = "/">
<Html>
<Body>
<Xsl: apply-templates select = "order">
<Xsl: with-param name = "sortcolumn" select = "$ column"/>
<Xsl: with-param name = "sortorder" select = "$ order"/>
</Xsl: apply-templates>
</Body>
</Html>
</Xsl: template>
<Xsl: template match = "order">
<Xsl: param name = "sortcolumn"/>
<Xsl: param name = "sortorder"/>
<Table border = "1">
<Tr>
<Th> order number </th>
<Th> id </th>
<Th> description </th>
<Th> Price </th>
<Th> quantity </th>
<Th> Total </th>
</Tr>
<Xsl: apply-templates select = "item">
</Xsl: apply-templates>
</Table>
</Xsl: template>
<Xsl: template match = "item">
<Tr>
<Td> <xsl: value-of select = "../account"/> </td>
<Td> <xsl: value-of select = "sku"/> </td>
<Td> <xsl: value-of select = "description"/> </td>
<Td> <xsl: value-of select = "priceper"/> </td>
<Td> <xsl: value-of select = "quantity"/> </td>
<Td> <xsl: value-of select = "subtotal"/> </td>
</Tr>
</Xsl: template>
</Xsl: stylesheet>
Order. xml file
<? Xml version = "1.0" encoding = 'gb2312 '?>
<Order>
<Account> 9900234 </account>
<Item id = "1">
<SKUs> 1234 </sku>
<Priceper> 5.95 </priceper>
<Quantity> 100 </quantity>
<Subtotal> 595.00 </subtotal>
<Description> www.111cn.net </description>
</Item>
<Item id = "2">
<SKUs> 6234 </sku>
<Priceper> 22.00 </priceper>
<Quantity> 10 </quantity>
<Subtotal> 220.00 </subtotal>
<Description> Football </description>
</Item>
<Item id = "3">
<SKUs> 9982 </sku>
<Priceper> 2.50 </priceper>
<Quantity> 1000 </quantity>
<Subtotal> 2500.00 </subtotal>
<Description> mobile phone package </description>
</Item>
<Item id = "4">
<SKUs> 3256 </sku>
<Priceper> 389.00 </priceper>
<Quantity> 1 </quantity>
<Subtotal> 389.00 </subtotal>
<Description> mobile phone </description>
</Item>
<Numberitems> www.111cn.net </numberitems>
<Total> 3704.00 </total>
<Orderdate> 07/07/2002 </orderdate>
<Ordernumber> 8876 </ordernumber>
</Order>