The SetDisplayMode function determines how the page will be displayed. You can pass it zoom and layout parameters. Here we're using percent zoom and the viewer's default layout. Now, that we've set up a page, let's insert an image to make it look nicer and make it a link while we're at it. The SetXY function sets the position of x and y coordinates, where we want the title to appear. After that's done, we call the Cell function to print out a cell rectangle along with the text of our title.
We are passing the function the following parameters; width, height, text, border, ln, align and fill. The border is either 0 for no border or 1 for frame.
For ln we are using the default value 0, "C" to centre align the text inside it and 0 for fill. Had we used 1 for fill the rectangle would have been coloured in. With a value of 0 we are making it transparent. You have generated a PDF. Again we are setting the x and y positions of the text, but this time we are reducing the font size with the SetFontSize function. The write function will print the text to a PDF. The parameter 5 will set the line height. This is only relevant however, if there are multiple lines of text.
Here we are passing the function the name of the file and the destination, in this case "I". In the example, columns 4, 5 and 8 are generated internally. Unique ID's are defined for these columns, which are used when the columns are created with addCol. The method of the parent class must be called in the default branch! To illustrate the grouping function with subtotals, in the example for each month a subheading and a subtotal is issued.
In order to be able to react to a change of month, the class implements the property strMonth to hold the month of the current row, which is initialized with an empty string. The following steps are required:.
To determine whether a month change occurs before a new line is printed, the method XPDF::PreRow is overloaded in the example class. If the previous month is not an empty string this is the case when printing the first row If no strHeader parameter is passed to this function, only the internal calculation of the subtotals started again, but no subheading will be printed. Finally, the new month is stored in the strMonth property.
Changes to the data therefore also affect the calling code. In the example class, a data field is simply changed for a row with a fixed row number 47 and this line is preceeded with a corresponding subheading. In the case of a second fixed row 56 , only the data field is changed and the line then is printed without a subheading. The necessary files of the package are integrated via autoloader and the example class is included. First, an instance of the example class is created and some information and the headings are set.
With SetInfo , file information is set that is displayed in the created document under the document properties. After all document settings have been made, the table can be generated:. This call starts the creation of the table. In practice, in most cases the data will come from a database query or some other data source. Now we will be writing the PHP code in the same file index. In these blocks of code we will be handling the data which is submitted by the user and generating the pdf from it from the library mpdf.
All the PHP code is given below. Save my name, email, and website in this browser for the next time I comment. Skip to content. Leave a Reply Cancel reply Comment. Enter your name or username to comment. Enter your email address to comment. Enter your website URL optional.
0コメント