tailieunhanh - Phát triển web với PHP và MySQL - p 81
Generating Personalized Documents in Portable Document Format (PDF) CHAPTER 30 775 We will look at some of the parts of this script that are different from the previous examples. Visitors need to get their own details on a certificate, so we will create the document in memory rather than in a file. If we wrote it to a file, we would need to worry about mechanisms to create unique filenames, stop people from snooping into others’ certificates, and determine a way to delete older certificate files to free up hard drive space on our server. In order to create a document in. | Generating Personalized Documents in Portable Document Format PDF 775 Chapter 30 We will look at some of the parts of this script that are different from the previous examples. Visitors need to get their own details on a certificate so we will create the document in memory rather than in a file. If we wrote it to a file we would need to worry about mechanisms to create unique filenames stop people from snooping into others certificates and determine a way to delete older certificate files to free up hard drive space on our server. In order to create a document in memory we call pdf_open without parameters as follows pdf pdf_open Our simplified border will consist of three stripes a fat border and two thin borders one inside the main border and one outside. We will draw all of these as rectangles. To position the borders in such a way that we can easily alter the page size or the appearance of the borders we will base all the border positions on the variables that we already have width and height and a few new ones inset border and inner. We will use inset to specify how many points wide the border at the edge of the page is border to specify the thickness of the main border and inner to specify how wide the gap between the main border and the thin borders will be. If you have drawn with another graphics API drawing with PDFlib will present few surprises. If you haven t read Chapter 19 Generating Images you might find it helpful to do so as drawing images with the gd library is quite similar to drawing them with PDFlib. The thin borders are easy. To create a rectangle we use pdf_rect which requires as parameters the PDF document identifier the x and y coordinate of the rectangle s lower left corner and the width and height of the rectangle. Because we want our layout to be flexible we calculate these from the variables we have set. pdf_rect pdf inset- inner inset- inner width-2 inset- inner height-2 inset- inner The call to pdf_rect sets up a path in the shape of a
đang nạp các trang xem trước