1 | # Page Management
|
---|
2 |
|
---|
3 | [back](./README.md)
|
---|
4 |
|
---|
5 | To facilitate the layout, three specific tags have been added:
|
---|
6 |
|
---|
7 | * `<page>`
|
---|
8 | * `<page_header>`
|
---|
9 | * `<page_footer>`
|
---|
10 |
|
---|
11 | They must be used as follow:
|
---|
12 |
|
---|
13 | ```html
|
---|
14 | <page>
|
---|
15 | <page_header>
|
---|
16 | ...
|
---|
17 | </page_header>
|
---|
18 | <page_footer>
|
---|
19 | ...
|
---|
20 | </page_footer>
|
---|
21 | ...
|
---|
22 | </page>
|
---|
23 | ```
|
---|
24 |
|
---|
25 | You **must not** use `<body>` and `<html>` tags.
|
---|
26 |
|
---|
27 | ## Page tag
|
---|
28 |
|
---|
29 | ### Attributes
|
---|
30 |
|
---|
31 | You can use the main following attributes:
|
---|
32 |
|
---|
33 | Attribute| Default | Description
|
---|
34 | ---------|---------|-------------
|
---|
35 | pageset | new | Specify if we want to use the previous page definition (old) or a new one (new)
|
---|
36 | pagegroup | old | Specify if we are in the same page group (old) or in a new one (new)
|
---|
37 | hideheader | | comma-separate page numbers on which we want to hide the header
|
---|
38 | hidefooter | | comma-separate page numbers on which we want to hide the footer
|
---|
39 | orientation | | Portrait (P) or Lanscape (L). By default, the orientation specified in the Html2Pdf constructor
|
---|
40 | format | | Format to use The list of the available values are [here](https://github.com/tecnickcom/TCPDF/blob/master/include/tcpdf_static.php#L2097). By default, the orientation specified in the Html2Pdf constructor
|
---|
41 | style | | css style
|
---|
42 | class | | css class
|
---|
43 |
|
---|
44 | You can use the following attributes to manage page margin:
|
---|
45 |
|
---|
46 | Attribute| Default | Description
|
---|
47 | ---------|---------|-------------
|
---|
48 | backtop | 0 | value with unit (mm, px, pt, % )
|
---|
49 | backbottom | 0 | value with unit (mm, px, pt, % )
|
---|
50 | backleft | 0 | value with unit (mm, px, pt, % )
|
---|
51 | backright | 0 | value with unit (mm, px, pt, % )
|
---|
52 |
|
---|
53 | You can use the following attributes to manage page background:
|
---|
54 |
|
---|
55 | Attribute| Default | Description
|
---|
56 | ---------|---------|-------------
|
---|
57 | backcolor | transparent | css color value
|
---|
58 | backimg | | url of the image to use
|
---|
59 | backimgx | center | x position of the image on the page background: left / center / right / value with unit (mm, px, pt, % )
|
---|
60 | backimgy | middle | y position of the image on the page background: top / middle / bottom / value with unit (mm, px, pt, % )
|
---|
61 | backimgw | 100% | width on the image on the page background: value with unit (mm, px, pt, % )
|
---|
62 |
|
---|
63 | You can add a light footer by using the attribute footer. It takes coma-separated values:
|
---|
64 |
|
---|
65 | Value| Description
|
---|
66 | -----|-------------
|
---|
67 | page | display the current page
|
---|
68 | date | display the generation date
|
---|
69 | time | display the generation time
|
---|
70 | form | display a disclamer about form compatibility
|
---|
71 |
|
---|
72 | ### explanation
|
---|
73 |
|
---|
74 | It allows to define, for the entire html code included within the layout :
|
---|
75 |
|
---|
76 | * margins left, right, top, bottom (backleft, backright, backtop, backbottom)
|
---|
77 | * background image, with its position and size (backimg, backimgx, backimgy, backimgw)
|
---|
78 | * the background color (backcolor)
|
---|
79 | * orientation (orientation) and format (format)
|
---|
80 | * simple automatic footer (footer)
|
---|
81 | * a header and a footer complex HTML (using tags page_header and page_footer).
|
---|
82 |
|
---|
83 | It does not limit it-self to one final page of the PDF, but to a set of pages.
|
---|
84 |
|
---|
85 | Any HTML code will be included automatically within the same layout.
|
---|
86 |
|
---|
87 | It is possible to reuse the layout of the previous tag page using property pageset = âold.â This also automatically resume the header and the footer.
|
---|
88 |
|
---|
89 | ## Page Header tag
|
---|
90 |
|
---|
91 | Its allows you to use complex HTML as the header of the current page.
|
---|
92 |
|
---|
93 | Its definition must necessarily be located just after the opening of the `<page>` tag.
|
---|
94 |
|
---|
95 | It can contain any valid HTML.
|
---|
96 |
|
---|
97 | It is **REQUIRED** to specify the top margin, using the `backtop` attribute on the `<page>` tag.
|
---|
98 |
|
---|
99 | You can use Ì`css` and `class` attribute on this specific tag.
|
---|
100 |
|
---|
101 | ## Page Footer tag
|
---|
102 |
|
---|
103 | Its allows you to use complex HTML as the header of the current page.
|
---|
104 |
|
---|
105 | Its definition must necessarily be located just after the opening of the `<page>` tag.
|
---|
106 |
|
---|
107 | It can contain any valid HTML.
|
---|
108 |
|
---|
109 | It is **REQUIRED** to specify the top margin, using the `backtop` attribute on the `<page>` tag.
|
---|
110 |
|
---|
111 | You can use `css` and `class` attribute on this specific tag.
|
---|
112 |
|
---|
113 | ## Margin Explanation
|
---|
114 |
|
---|
115 | Here's a little explanation of different margins:
|
---|
116 |
|
---|
117 | ```html
|
---|
118 | <page backtop="7mm" backbottom="7mm" backleft="10mm" backright="10mm">
|
---|
119 | <page_header>
|
---|
120 | Page Header
|
---|
121 | </page_header>
|
---|
122 | <page_footer>
|
---|
123 | Page Footer
|
---|
124 | </page_footer>
|
---|
125 |
|
---|
126 | Page Content
|
---|
127 | </page>
|
---|
128 | ```
|
---|
129 |
|
---|
130 | ```php
|
---|
131 | $pdf = new \Spipu\Html2Pdf\Html2Pdf('P','A4','en', false, 'UTF-8', array(mL, mT, mR, mB));
|
---|
132 | $pdf->writeHTML($htmlContent);
|
---|
133 | $pdf->Output();
|
---|
134 | ```
|
---|
135 |
|
---|
136 | ![Margins](res/margins.jpg "Margins")
|
---|
137 |
|
---|
138 | [back](./README.md)
|
---|