[347] | 1 | # Bookmark
|
---|
| 2 |
|
---|
| 3 | [back](./README.md)
|
---|
| 4 |
|
---|
| 5 | ## tag bookmark
|
---|
| 6 |
|
---|
| 7 | You can add automatic bookmark, by directly inserting the `<bookmark>` tag in the HTML to convert :
|
---|
| 8 |
|
---|
| 9 | ```html
|
---|
| 10 | <bookmark title="My Title" level="0" ></bookmark>
|
---|
| 11 | ```
|
---|
| 12 |
|
---|
| 13 | ### attributes
|
---|
| 14 |
|
---|
| 15 | Attribute| Default | Description
|
---|
| 16 | ---------|---------|-------------
|
---|
| 17 | title | | Title of the bookmark
|
---|
| 18 | level | 0 | Level of the bookmark, must be a positive integer. Level 0 is the main level
|
---|
| 19 |
|
---|
| 20 | ## Page Index
|
---|
| 21 |
|
---|
| 22 | You can insert an index (summary) of all bookmarks automatically, using the following function :
|
---|
| 23 |
|
---|
| 24 | ```php
|
---|
| 25 | $html2pdf->createIndex($titre, $sizeTitle, $sizeBookmark, $bookmarkTitle, $displayPage, $onPage, $fontName, $marginTop);
|
---|
| 26 | ```
|
---|
| 27 |
|
---|
| 28 | ### parameters
|
---|
| 29 |
|
---|
| 30 | Parameter| Default | Description
|
---|
| 31 | ---------|---------|-------------
|
---|
| 32 | $title | Index | index title
|
---|
| 33 | $sizeTitle | 20 | font size of the index title, in mm
|
---|
| 34 | $sizeBookmark | 15 | font size of the index, in mm
|
---|
| 35 | $bookmarkTitle | true | add a bookmark for the index, at his beginning
|
---|
| 36 | $displayPage | true | display the page numbers
|
---|
| 37 | $onPage | null | if null : at the end of the document on a new page, else on the $onPage page
|
---|
| 38 | $fontName | null | font name to use. If null, use helvetica
|
---|
| 39 | $marginTop | null | margin top to use on the index page
|
---|
| 40 |
|
---|
| 41 | **IMPORTANT**:
|
---|
| 42 | If you want the summary index on a specific page (using $onPage) you must have anticipated this page during the creation of HTML (see example below).
|
---|
| 43 | Furthermore, if the summary index takes more than one page, you must have provided the necessary number of pages...
|
---|
| 44 |
|
---|
| 45 | ## Example with automatic index on last page
|
---|
| 46 |
|
---|
| 47 | ```html
|
---|
| 48 | <style type="text/css">
|
---|
| 49 | <!--
|
---|
| 50 | table.page_header {width: 100%; border: none; background-color: #DDDDFF; border-bottom: solid 1mm #AAAADD; padding: 2mm }
|
---|
| 51 | table.page_footer {width: 100%; border: none; background-color: #DDDDFF; border-top: solid 1mm #AAAADD; padding: 2mm}
|
---|
| 52 | h1 {color: #000033}
|
---|
| 53 | h2 {color: #000055}
|
---|
| 54 | h3 {color: #000077}
|
---|
| 55 |
|
---|
| 56 | div.standard
|
---|
| 57 | {
|
---|
| 58 | padding-left: 5mm;
|
---|
| 59 | }
|
---|
| 60 | -->
|
---|
| 61 | </style>
|
---|
| 62 | <page backtop="14mm" backbottom="14mm" backleft="10mm" backright="10mm" style="font-size: 12pt">
|
---|
| 63 | <page_header>
|
---|
| 64 | <table class="page_header">
|
---|
| 65 | <tr>
|
---|
| 66 | <td style="width: 100%; text-align: left">
|
---|
| 67 | Example of using bookmarks
|
---|
| 68 | </td>
|
---|
| 69 | </tr>
|
---|
| 70 | </table>
|
---|
| 71 | </page_header>
|
---|
| 72 | <page_footer>
|
---|
| 73 | <table class="page_footer">
|
---|
| 74 | <tr>
|
---|
| 75 | <td style="width: 100%; text-align: right">
|
---|
| 76 | page [[page_cu]]/[[page_nb]]
|
---|
| 77 | </td>
|
---|
| 78 | </tr>
|
---|
| 79 | </table>
|
---|
| 80 | </page_footer>
|
---|
| 81 | <bookmark title="Chapter 1" level="0" ></bookmark><h1>Chapter 1</h1>
|
---|
| 82 | <div class="standard">
|
---|
| 83 | Contents of Chapter 1
|
---|
| 84 | </div>
|
---|
| 85 | </page>
|
---|
| 86 | <page pageset="old">
|
---|
| 87 | <bookmark title="Chapter 2" level="0" ></bookmark><h1>Chapter 2</h1>
|
---|
| 88 | <div class="standard">
|
---|
| 89 | Intro to Chapter 2
|
---|
| 90 | <bookmark title="Chapter 2.1" level="1" ></bookmark><h2>Chapter 2.1</h2>
|
---|
| 91 | <div class="standard">
|
---|
| 92 | Contents of Chapter 2.1
|
---|
| 93 | </div>
|
---|
| 94 | <bookmark title="Chapter 2.2" level="1" ></bookmark><h2>Chapter 2.2</h2>
|
---|
| 95 | <div class="standard">
|
---|
| 96 | Contents of Chapter 2.2
|
---|
| 97 | </div>
|
---|
| 98 | <bookmark title="Chapter 2.3" level="1" ></bookmark><h2>Chapter 2.3</h2>
|
---|
| 99 | <div class="standard">
|
---|
| 100 | Contents of Chapter 2.3
|
---|
| 101 | </div>
|
---|
| 102 | </div>
|
---|
| 103 | </page>
|
---|
| 104 | <page pageset="old">
|
---|
| 105 | <bookmark title="Chapter 3" level="0" ></bookmark><h1>Chapter 3</h1>
|
---|
| 106 | <div class="standard">
|
---|
| 107 | Intro to Chapter 3
|
---|
| 108 | <bookmark title="Chapter 3.1" level="1" ></bookmark><h2>Chapter 3.1</h2>
|
---|
| 109 | <div class="standard">
|
---|
| 110 | Contents of Chapter 3.1
|
---|
| 111 | </div>
|
---|
| 112 | <bookmark title="Chapter 3.2" level="1" ></bookmark><h2>Chapter 3.2</h2>
|
---|
| 113 | <div class="standard">
|
---|
| 114 | Intro to Chapter 3.2
|
---|
| 115 | <bookmark title="Chapter 3.2.1" level="2" ></bookmark><h3>Chapter 3.2.1</h3>
|
---|
| 116 | <div class="standard">
|
---|
| 117 | Contents of Chapter 3.2.1
|
---|
| 118 | </div>
|
---|
| 119 | <bookmark title="Chapter 3.2.2" level="2" ></bookmark><h3>Chapter 3.2.2</h3>
|
---|
| 120 | <div class="standard">
|
---|
| 121 | Contents of Chapter 3.2.2
|
---|
| 122 | </div>
|
---|
| 123 | </div>
|
---|
| 124 | </div>
|
---|
| 125 | </page>
|
---|
| 126 | ```
|
---|
| 127 |
|
---|
| 128 | ```php
|
---|
| 129 | $html2pdf = new Spipu\Html2Pdf\Html2Pdf('P','A4','en');
|
---|
| 130 | $html2pdf->writeHTML($html);
|
---|
| 131 | $html2pdf->createIndex('Summary', 25, 12, true, true);
|
---|
| 132 | $html2pdf->output();
|
---|
| 133 | ```
|
---|
| 134 |
|
---|
| 135 | ## Example with automatic index on specific page
|
---|
| 136 |
|
---|
| 137 | ```html
|
---|
| 138 | <style type="text/css">
|
---|
| 139 | <!--
|
---|
| 140 | table.page_header {width: 100%; border: none; background-color: #DDDDFF; border-bottom: solid 1mm #AAAADD; padding: 2mm }
|
---|
| 141 | table.page_footer {width: 100%; border: none; background-color: #DDDDFF; border-top: solid 1mm #AAAADD; padding: 2mm}
|
---|
| 142 | h1 {color: #000033}
|
---|
| 143 | h2 {color: #000055}
|
---|
| 144 | h3 {color: #000077}
|
---|
| 145 |
|
---|
| 146 | div.standard
|
---|
| 147 | {
|
---|
| 148 | padding-left: 5mm;
|
---|
| 149 | }
|
---|
| 150 | -->
|
---|
| 151 | </style>
|
---|
| 152 | <page backtop="14mm" backbottom="14mm" backleft="10mm" backright="10mm" style="font-size: 12pt">
|
---|
| 153 | <page_header>
|
---|
| 154 | <table class="page_header">
|
---|
| 155 | <tr>
|
---|
| 156 | <td style="width: 100%; text-align: left">
|
---|
| 157 | Example of using bookmarks
|
---|
| 158 | </td>
|
---|
| 159 | </tr>
|
---|
| 160 | </table>
|
---|
| 161 | </page_header>
|
---|
| 162 | <page_footer>
|
---|
| 163 | <table class="page_footer">
|
---|
| 164 | <tr>
|
---|
| 165 | <td style="width: 100%; text-align: right">
|
---|
| 166 | page [[page_cu]]/[[page_nb]]
|
---|
| 167 | </td>
|
---|
| 168 | </tr>
|
---|
| 169 | </table>
|
---|
| 170 | </page_footer>
|
---|
| 171 | <bookmark title="Summary" level="0" ></bookmark>
|
---|
| 172 | </page>
|
---|
| 173 | <page pageset="old">
|
---|
| 174 | <bookmark title="Chapter 1" level="0" ></bookmark><h1>Chapter 1</h1>
|
---|
| 175 | <div class="standard">
|
---|
| 176 | Contents of Chapter 1
|
---|
| 177 | </div>
|
---|
| 178 | </page>
|
---|
| 179 | <page pageset="old">
|
---|
| 180 | <bookmark title="Chapter 2" level="0" ></bookmark><h1>Chapter 2</h1>
|
---|
| 181 | <div class="standard">
|
---|
| 182 | Intro to Chapter 2
|
---|
| 183 | <bookmark title="Chapter 2.1" level="1" ></bookmark><h2>Chapter 2.1</h2>
|
---|
| 184 | <div class="standard">
|
---|
| 185 | Contents of Chapter 2.1
|
---|
| 186 | </div>
|
---|
| 187 | <bookmark title="Chapter 2.2" level="1" ></bookmark><h2>Chapter 2.2</h2>
|
---|
| 188 | <div class="standard">
|
---|
| 189 | Contents of Chapter 2.2
|
---|
| 190 | </div>
|
---|
| 191 | <bookmark title="Chapter 2.3" level="1" ></bookmark><h2>Chapter 2.3</h2>
|
---|
| 192 | <div class="standard">
|
---|
| 193 | Contents of Chapter 2.3
|
---|
| 194 | </div>
|
---|
| 195 | </div>
|
---|
| 196 | </page>
|
---|
| 197 | <page pageset="old">
|
---|
| 198 | <bookmark title="Chapter 3" level="0" ></bookmark><h1>Chapter 3</h1>
|
---|
| 199 | <div class="standard">
|
---|
| 200 | Intro to Chapter 3
|
---|
| 201 | <bookmark title="Chapter 3.1" level="1" ></bookmark><h2>Chapter 3.1</h2>
|
---|
| 202 | <div class="standard">
|
---|
| 203 | Contents of Chapter 3.1
|
---|
| 204 | </div>
|
---|
| 205 | <bookmark title="Chapter 3.2" level="1" ></bookmark><h2>Chapter 3.2</h2>
|
---|
| 206 | <div class="standard">
|
---|
| 207 | Intro to Chapter 3.2
|
---|
| 208 | <bookmark title="Chapter 3.2.1" level="2" ></bookmark><h3>Chapter 3.2.1</h3>
|
---|
| 209 | <div class="standard">
|
---|
| 210 | Contents of Chapter 3.2.1
|
---|
| 211 | </div>
|
---|
| 212 | <bookmark title="Chapter 3.2.2" level="2" ></bookmark><h3>Chapter 3.2.2</h3>
|
---|
| 213 | <div class="standard">
|
---|
| 214 | Contents of Chapter 3.2.2
|
---|
| 215 | </div>
|
---|
| 216 | </div>
|
---|
| 217 | </div>
|
---|
| 218 | </page>
|
---|
| 219 | ```
|
---|
| 220 |
|
---|
| 221 | ```php
|
---|
| 222 | $html2pdf = new Spipu\Html2Pdf\Html2Pdf('P','A4','en');
|
---|
| 223 | $html2pdf->writeHTML($html);
|
---|
| 224 | $html2pdf->createIndex('Summary', 25, 12, false, true, 1);
|
---|
| 225 | $html2pdf->output();
|
---|
| 226 | ```
|
---|
| 227 |
|
---|
| 228 | [back](./README.md)
|
---|