source: trunk/client/inc/hpdf5/spipu/html2pdf/doc/page.md@ 347

Last change on this file since 347 was 347, checked in by roby, 3 years ago

Aggiornamento per compatibilità con php7.4

File size: 4.3 KB
Line 
1# Page Management
2
3[back](./README.md)
4
5To facilitate the layout, three specific tags have been added:
6
7 * `<page>`
8 * `<page_header>`
9 * `<page_footer>`
10
11They 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
25You **must not** use `<body>` and `<html>` tags.
26
27## Page tag
28
29### Attributes
30
31You can use the main following attributes:
32
33Attribute| Default | Description
34---------|---------|-------------
35pageset | new | Specify if we want to use the previous page definition (old) or a new one (new)
36pagegroup | old | Specify if we are in the same page group (old) or in a new one (new)
37hideheader | | comma-separate page numbers on which we want to hide the header
38hidefooter | | comma-separate page numbers on which we want to hide the footer
39orientation | | Portrait (P) or Lanscape (L). By default, the orientation specified in the Html2Pdf constructor
40format | | 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
41style | | css style
42class | | css class
43
44You can use the following attributes to manage page margin:
45
46Attribute| Default | Description
47---------|---------|-------------
48backtop | 0 | value with unit (mm, px, pt, % )
49backbottom | 0 | value with unit (mm, px, pt, % )
50backleft | 0 | value with unit (mm, px, pt, % )
51backright | 0 | value with unit (mm, px, pt, % )
52
53You can use the following attributes to manage page background:
54
55Attribute| Default | Description
56---------|---------|-------------
57backcolor | transparent | css color value
58backimg | | url of the image to use
59backimgx | center | x position of the image on the page background: left / center / right / value with unit (mm, px, pt, % )
60backimgy | middle | y position of the image on the page background: top / middle / bottom / value with unit (mm, px, pt, % )
61backimgw | 100% | width on the image on the page background: value with unit (mm, px, pt, % )
62
63You can add a light footer by using the attribute footer. It takes coma-separated values:
64
65Value| Description
66-----|-------------
67page | display the current page
68date | display the generation date
69time | display the generation time
70form | display a disclamer about form compatibility
71
72### explanation
73
74It 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
83It does not limit it-self to one final page of the PDF, but to a set of pages.
84
85Any HTML code will be included automatically within the same layout.
86
87It 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
91Its allows you to use complex HTML as the header of the current page.
92
93Its definition must necessarily be located just after the opening of the `<page>` tag.
94
95It can contain any valid HTML.
96
97It is **REQUIRED** to specify the top margin, using the `backtop` attribute on the `<page>` tag.
98
99You can use ̀`css` and `class` attribute on this specific tag.
100
101## Page Footer tag
102
103Its allows you to use complex HTML as the header of the current page.
104
105Its definition must necessarily be located just after the opening of the `<page>` tag.
106
107It can contain any valid HTML.
108
109It is **REQUIRED** to specify the top margin, using the `backtop` attribute on the `<page>` tag.
110
111You can use `css` and `class` attribute on this specific tag.
112
113## Margin Explanation
114
115Here'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)
Note: See TracBrowser for help on using the repository browser.