Initial commit
This commit is contained in:
68
html2pdf-master/doc/README.md
Normal file
68
html2pdf-master/doc/README.md
Normal file
@ -0,0 +1,68 @@
|
||||
# Html2Pdf Documentation
|
||||
|
||||
|
||||
## Documentation
|
||||
|
||||
* [How to Install Html2Pdf](./install.md)
|
||||
* [Basic Usage](./basic.md)
|
||||
* [Page and Margin](./page.md)
|
||||
* [Output](./output.md)
|
||||
* [Barcode](./barcode.md)
|
||||
* [Bookmark](./bookmark.md)
|
||||
* [Font](./font.md)
|
||||
* [SVG](./svg.md)
|
||||
* [Electronic Signature](./cert.md)
|
||||
* [Extensions](./extension.md)
|
||||
* [Exceptions](./exception.md)
|
||||
* [Useful Methods](./methods.md)
|
||||
* [Tcpdf Methods](./tcpdf_methods.md)
|
||||
|
||||
## Recommandations
|
||||
|
||||
* It is very important to provide valid HTML 4.01 to the converter, but only what is in the `<body>`.
|
||||
* Use the `<page>` tag. Does not use the `<html>` or `<body>` tag.
|
||||
* for borders: it is advised that they are like `solid 1mm #000000`
|
||||
* for padding, they are applicable only on tags `table`, `th`, `td`, `div`, `li`
|
||||
* A default font can be specified, if the requested font does not exist or if no font is specified: `$html2pdf->setDefaultFont('Arial');`
|
||||
* The possibility to protect your PDF is present, CF Example 7.
|
||||
* Some tests can be enabled (true) or disabled (false):
|
||||
|
||||
* `setTestIsImage` method: test that images must exist
|
||||
* `setTestTdInOnePage` method: test that the contents of TDs fit on one page
|
||||
|
||||
* A DEBUG mode to know the resources used is present. It is activated by adding the following command just after the contructor (see Example 0): `$html2pdf->setModeDebug();`
|
||||
* Some specific tags have been introduced:
|
||||
|
||||
* `<page></page>` (CF Exemple 7)
|
||||
|
||||
* Determines the orientation, margins left, right, top and bottom, the background image and the background color of a page, its size and position, the footer.
|
||||
* It is also possible to keep the header and footer of the previous pages, through the attribut `pageset="old"` (see Example 3 & 4)
|
||||
|
||||
* `<page_header></page_header>` (CF Example 3)
|
||||
* `<page_footer></page_footer>` (CF Example 3)
|
||||
* `<nobreak></nobreak>`
|
||||
|
||||
* Used to force the display of a section on the same page.
|
||||
* If this section does not fit into the rest of the page, a page break is done before.
|
||||
|
||||
* `<barcode></barcode>` (CF Examples 0 & 9)
|
||||
|
||||
* Can insert barcodes in pdfs, CF Examples 0 and 9.
|
||||
* the possible types of codebar are alls of TCPDF.
|
||||
|
||||
* `<qrcode></qrcode>` (CF Example 13)
|
||||
|
||||
* can insert QRcode 2D barcodes
|
||||
* (QR Code is registered trademark of DENSO WAVE INCORPORATED)
|
||||
|
||||
* `<bookmark></bookmark>` (CF Examples 7 & About)
|
||||
|
||||
* Can insert bookmark in pdfs, CF Example 7 and About.
|
||||
* It is also possible to automatically create an index at the end of document (CF Example About)
|
||||
|
||||
* `<end_last_page end_height="30mm"></end_last_page>` (CF Example 5)
|
||||
|
||||
* css property `rotate`:
|
||||
|
||||
* Values : 0, 90, 180, 270
|
||||
* Works only on div (cf example 8)
|
89
html2pdf-master/doc/barcode.md
Normal file
89
html2pdf-master/doc/barcode.md
Normal file
@ -0,0 +1,89 @@
|
||||
# BarCode
|
||||
|
||||
[back](./README.md)
|
||||
|
||||
## tag barcode
|
||||
|
||||
You can add barcode, by directly inserting the `<barcode>` tag in the HTML to convert :
|
||||
|
||||
```html
|
||||
<barcode dimension="1D" type="EAN13" value="45" label="label" style="width:30mm; height:6mm; color: #770000; font-size: 4mm"></barcode>
|
||||
```
|
||||
|
||||
### attributes
|
||||
|
||||
Attribute| Default | Description
|
||||
---------|---------|-------------
|
||||
dimension | 1D | create a 1D or 2D barcode
|
||||
type| C39 | type of barcode to use
|
||||
value| 0 | value to convert into barcode
|
||||
label| label | indicates that the label must be present below the bar code (label) or not (none) (not required)
|
||||
style| | sets the color for the bar, its width and height (without the label) and the size of the label if it is displayed (not required)
|
||||
|
||||
### 1D types
|
||||
|
||||
For 1D bar-codes, the possible values for `type` attribute are:
|
||||
|
||||
Type| Description
|
||||
----|------------
|
||||
C39| CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.
|
||||
C39+| CODE 39 with checksum
|
||||
C39E| CODE 39 EXTENDED
|
||||
C39E+| CODE 39 EXTENDED + CHECKSUM
|
||||
C93| CODE 93 - USS-93
|
||||
S25| Standard 2 of 5
|
||||
S25+| Standard 2 of 5 + CHECKSUM
|
||||
I25| Interleaved 2 of 5
|
||||
I25+| Interleaved 2 of 5 + CHECKSUM
|
||||
C128| CODE 128
|
||||
C128A| CODE 128 A
|
||||
C128B| CODE 128 B
|
||||
C128C| CODE 128 C
|
||||
EAN2| 2-Digits UPC-Based Extension
|
||||
EAN5| 5-Digits UPC-Based Extension
|
||||
EAN8| EAN 8
|
||||
EAN13| EAN 13
|
||||
UPCA| UPC-A
|
||||
UPCE| UPC-E
|
||||
MSI| MSI (Variation of Plessey code)
|
||||
MSI+| MSI + CHECKSUM (modulo 11)
|
||||
POSTNET| POSTNET
|
||||
PLANET| PLANET
|
||||
RMS4CC| RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)
|
||||
KIX| KIX (Klant index - Customer index)
|
||||
IMB| IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200
|
||||
IMBPRE| IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200- pre-processed
|
||||
CODABAR| CODABAR
|
||||
CODE11| CODE 11
|
||||
PHARMA| PHARMACODE
|
||||
PHARMA2T| PHARMACODE TWO-TRACKS
|
||||
|
||||
### 2D types
|
||||
|
||||
For 2D barcodes, the possible values for `type` attribute are:
|
||||
|
||||
Type| Description
|
||||
----|------------
|
||||
DATAMATRIX| DATAMATRIX (ISO/IEC 16022)
|
||||
PDF417| PDF417 (ISO/IEC 15438:2006)
|
||||
QRCODE| QR-CODE
|
||||
RAW| RAW MODE
|
||||
RAW2| RAW MODE
|
||||
|
||||
## tag qrcode
|
||||
|
||||
You can directly add bar-codes to two-dimensional QR-Code, by inserting the tag QRcode directly in the HTML to convert:
|
||||
|
||||
```html
|
||||
<qrcode value="Value to Coder" ec="H" style="width: 50mm; background-color: white; color: black;"></qrcode>
|
||||
```
|
||||
|
||||
### attributes
|
||||
|
||||
Attribute| Default | Description
|
||||
---------|---------|-------------
|
||||
value| | value to convert into barcode
|
||||
ec| H | level of error correction (L, M, Q, H)
|
||||
style| | sets the width, color, background-color, and border of the qrcode
|
||||
|
||||
[back](./README.md)
|
75
html2pdf-master/doc/basic.md
Normal file
75
html2pdf-master/doc/basic.md
Normal file
@ -0,0 +1,75 @@
|
||||
# Basic Usage
|
||||
|
||||
[back](./README.md)
|
||||
|
||||
## PHP Constructor
|
||||
|
||||
The main class of this library is `\Spipu\Html2Pdf\Html2Pdf`.
|
||||
|
||||
The PHP constructor takes the following parameters:
|
||||
|
||||
Variable | Default value |Description
|
||||
---------|---------------|--------------
|
||||
$orientation | P | The default page orientation, can be P (portrait) or L (landscape)
|
||||
$format | A4 | The default page format used for pages. The list of the available value are [here](https://github.com/tecnickcom/TCPDF/blob/485956db63b5a225760e80fa2278bdb22eca4650/include/tcpdf_static.php#L2129). You can also give a array with 2 values the width and the height in mm.
|
||||
$lang | fr | Language to use, for some minor translations. The list of the available languages are [here](https://github.com/spipu/html2pdf/tree/master/src/locale)
|
||||
$unicode | true | means that the input HTML string is unicode
|
||||
$encoding |UTF-8 | charset encoding of the input HTML string
|
||||
$margins | array(5, 5, 5, 8) | Main margins of the page (left, top, right, bottom) in mm
|
||||
$pdfa | false | If TRUE set the document to PDF/A mode
|
||||
|
||||
In most of the case, you will just use the 3 first parameters :
|
||||
|
||||
```php
|
||||
$html2pdf = new \Spipu\Html2Pdf\Html2Pdf('P', 'A4', 'en');
|
||||
```
|
||||
|
||||
## Convert the HTML
|
||||
|
||||
The main method to use is `writeHTML`.
|
||||
|
||||
It takes one parameter : the HTML in string format that you want to convert into PDF.
|
||||
|
||||
```php
|
||||
$html2pdf->writeHTML('<h1>HelloWorld</h1>This is my first test');
|
||||
```
|
||||
|
||||
You can call it more than one time, if you want to split the conversion in order to use less memory. It will continue on the same page, directly at the end of the last converted part.
|
||||
|
||||
```php
|
||||
$html2pdf->writeHTML('<h1>HelloWorld</h1>This is my first text');
|
||||
$html2pdf->writeHTML('<h1>HelloWorld</h1>This is my second text');
|
||||
```
|
||||
|
||||
If you want to separate on a new page, you can use the specific HTML tag `page`.
|
||||
|
||||
```php
|
||||
$html2pdf->writeHTML('<page><h1>HelloWorld</h1>This is my first page</page>');
|
||||
$html2pdf->writeHTML('<page><h1>HelloWorld</h1>This is my second page</page>');
|
||||
```
|
||||
|
||||
You can find more information about this specific tag on the [page](page.md) documentation.
|
||||
|
||||
## Get the PDF
|
||||
|
||||
The main method to use is `output`.
|
||||
|
||||
It takes two not required parameters. You can find more information on the [output](output.md) documentation.
|
||||
|
||||
If you do not give any parameters, it will send the PDF file to the browser, to display it.
|
||||
|
||||
```php
|
||||
$html2pdf->output();
|
||||
```
|
||||
|
||||
## Full Example
|
||||
|
||||
Here is the full code for a helloworld example:
|
||||
|
||||
```php
|
||||
$html2pdf = new \Spipu\Html2Pdf\Html2Pdf('P', 'A4', 'en');
|
||||
$html2pdf->writeHTML('<h1>HelloWorld</h1>This is my first page');
|
||||
$html2pdf->output();
|
||||
```
|
||||
|
||||
[back](./README.md)
|
228
html2pdf-master/doc/bookmark.md
Normal file
228
html2pdf-master/doc/bookmark.md
Normal file
@ -0,0 +1,228 @@
|
||||
# Bookmark
|
||||
|
||||
[back](./README.md)
|
||||
|
||||
## tag bookmark
|
||||
|
||||
You can add automatic bookmark, by directly inserting the `<bookmark>` tag in the HTML to convert :
|
||||
|
||||
```html
|
||||
<bookmark title="My Title" level="0" ></bookmark>
|
||||
```
|
||||
|
||||
### attributes
|
||||
|
||||
Attribute| Default | Description
|
||||
---------|---------|-------------
|
||||
title | | Title of the bookmark
|
||||
level | 0 | Level of the bookmark, must be a positive integer. Level 0 is the main level
|
||||
|
||||
## Page Index
|
||||
|
||||
You can insert an index (summary) of all bookmarks automatically, using the following function :
|
||||
|
||||
```php
|
||||
$html2pdf->createIndex($titre, $sizeTitle, $sizeBookmark, $bookmarkTitle, $displayPage, $onPage, $fontName, $marginTop);
|
||||
```
|
||||
|
||||
### parameters
|
||||
|
||||
Parameter| Default | Description
|
||||
---------|---------|-------------
|
||||
$title | Index | index title
|
||||
$sizeTitle | 20 | font size of the index title, in mm
|
||||
$sizeBookmark | 15 | font size of the index, in mm
|
||||
$bookmarkTitle | true | add a bookmark for the index, at his beginning
|
||||
$displayPage | true | display the page numbers
|
||||
$onPage | null | if null : at the end of the document on a new page, else on the $onPage page
|
||||
$fontName | null | font name to use. If null, use helvetica
|
||||
$marginTop | null | margin top to use on the index page
|
||||
|
||||
**IMPORTANT**:
|
||||
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).
|
||||
Furthermore, if the summary index takes more than one page, you must have provided the necessary number of pages...
|
||||
|
||||
## Example with automatic index on last page
|
||||
|
||||
```html
|
||||
<style type="text/css">
|
||||
<!--
|
||||
table.page_header {width: 100%; border: none; background-color: #DDDDFF; border-bottom: solid 1mm #AAAADD; padding: 2mm }
|
||||
table.page_footer {width: 100%; border: none; background-color: #DDDDFF; border-top: solid 1mm #AAAADD; padding: 2mm}
|
||||
h1 {color: #000033}
|
||||
h2 {color: #000055}
|
||||
h3 {color: #000077}
|
||||
|
||||
div.standard
|
||||
{
|
||||
padding-left: 5mm;
|
||||
}
|
||||
-->
|
||||
</style>
|
||||
<page backtop="14mm" backbottom="14mm" backleft="10mm" backright="10mm" style="font-size: 12pt">
|
||||
<page_header>
|
||||
<table class="page_header">
|
||||
<tr>
|
||||
<td style="width: 100%; text-align: left">
|
||||
Example of using bookmarks
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</page_header>
|
||||
<page_footer>
|
||||
<table class="page_footer">
|
||||
<tr>
|
||||
<td style="width: 100%; text-align: right">
|
||||
page [[page_cu]]/[[page_nb]]
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</page_footer>
|
||||
<bookmark title="Chapter 1" level="0" ></bookmark><h1>Chapter 1</h1>
|
||||
<div class="standard">
|
||||
Contents of Chapter 1
|
||||
</div>
|
||||
</page>
|
||||
<page pageset="old">
|
||||
<bookmark title="Chapter 2" level="0" ></bookmark><h1>Chapter 2</h1>
|
||||
<div class="standard">
|
||||
Intro to Chapter 2
|
||||
<bookmark title="Chapter 2.1" level="1" ></bookmark><h2>Chapter 2.1</h2>
|
||||
<div class="standard">
|
||||
Contents of Chapter 2.1
|
||||
</div>
|
||||
<bookmark title="Chapter 2.2" level="1" ></bookmark><h2>Chapter 2.2</h2>
|
||||
<div class="standard">
|
||||
Contents of Chapter 2.2
|
||||
</div>
|
||||
<bookmark title="Chapter 2.3" level="1" ></bookmark><h2>Chapter 2.3</h2>
|
||||
<div class="standard">
|
||||
Contents of Chapter 2.3
|
||||
</div>
|
||||
</div>
|
||||
</page>
|
||||
<page pageset="old">
|
||||
<bookmark title="Chapter 3" level="0" ></bookmark><h1>Chapter 3</h1>
|
||||
<div class="standard">
|
||||
Intro to Chapter 3
|
||||
<bookmark title="Chapter 3.1" level="1" ></bookmark><h2>Chapter 3.1</h2>
|
||||
<div class="standard">
|
||||
Contents of Chapter 3.1
|
||||
</div>
|
||||
<bookmark title="Chapter 3.2" level="1" ></bookmark><h2>Chapter 3.2</h2>
|
||||
<div class="standard">
|
||||
Intro to Chapter 3.2
|
||||
<bookmark title="Chapter 3.2.1" level="2" ></bookmark><h3>Chapter 3.2.1</h3>
|
||||
<div class="standard">
|
||||
Contents of Chapter 3.2.1
|
||||
</div>
|
||||
<bookmark title="Chapter 3.2.2" level="2" ></bookmark><h3>Chapter 3.2.2</h3>
|
||||
<div class="standard">
|
||||
Contents of Chapter 3.2.2
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</page>
|
||||
```
|
||||
|
||||
```php
|
||||
$html2pdf = new Spipu\Html2Pdf\Html2Pdf('P','A4','en');
|
||||
$html2pdf->writeHTML($html);
|
||||
$html2pdf->createIndex('Summary', 25, 12, true, true);
|
||||
$html2pdf->output();
|
||||
```
|
||||
|
||||
## Example with automatic index on specific page
|
||||
|
||||
```html
|
||||
<style type="text/css">
|
||||
<!--
|
||||
table.page_header {width: 100%; border: none; background-color: #DDDDFF; border-bottom: solid 1mm #AAAADD; padding: 2mm }
|
||||
table.page_footer {width: 100%; border: none; background-color: #DDDDFF; border-top: solid 1mm #AAAADD; padding: 2mm}
|
||||
h1 {color: #000033}
|
||||
h2 {color: #000055}
|
||||
h3 {color: #000077}
|
||||
|
||||
div.standard
|
||||
{
|
||||
padding-left: 5mm;
|
||||
}
|
||||
-->
|
||||
</style>
|
||||
<page backtop="14mm" backbottom="14mm" backleft="10mm" backright="10mm" style="font-size: 12pt">
|
||||
<page_header>
|
||||
<table class="page_header">
|
||||
<tr>
|
||||
<td style="width: 100%; text-align: left">
|
||||
Example of using bookmarks
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</page_header>
|
||||
<page_footer>
|
||||
<table class="page_footer">
|
||||
<tr>
|
||||
<td style="width: 100%; text-align: right">
|
||||
page [[page_cu]]/[[page_nb]]
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</page_footer>
|
||||
<bookmark title="Summary" level="0" ></bookmark>
|
||||
</page>
|
||||
<page pageset="old">
|
||||
<bookmark title="Chapter 1" level="0" ></bookmark><h1>Chapter 1</h1>
|
||||
<div class="standard">
|
||||
Contents of Chapter 1
|
||||
</div>
|
||||
</page>
|
||||
<page pageset="old">
|
||||
<bookmark title="Chapter 2" level="0" ></bookmark><h1>Chapter 2</h1>
|
||||
<div class="standard">
|
||||
Intro to Chapter 2
|
||||
<bookmark title="Chapter 2.1" level="1" ></bookmark><h2>Chapter 2.1</h2>
|
||||
<div class="standard">
|
||||
Contents of Chapter 2.1
|
||||
</div>
|
||||
<bookmark title="Chapter 2.2" level="1" ></bookmark><h2>Chapter 2.2</h2>
|
||||
<div class="standard">
|
||||
Contents of Chapter 2.2
|
||||
</div>
|
||||
<bookmark title="Chapter 2.3" level="1" ></bookmark><h2>Chapter 2.3</h2>
|
||||
<div class="standard">
|
||||
Contents of Chapter 2.3
|
||||
</div>
|
||||
</div>
|
||||
</page>
|
||||
<page pageset="old">
|
||||
<bookmark title="Chapter 3" level="0" ></bookmark><h1>Chapter 3</h1>
|
||||
<div class="standard">
|
||||
Intro to Chapter 3
|
||||
<bookmark title="Chapter 3.1" level="1" ></bookmark><h2>Chapter 3.1</h2>
|
||||
<div class="standard">
|
||||
Contents of Chapter 3.1
|
||||
</div>
|
||||
<bookmark title="Chapter 3.2" level="1" ></bookmark><h2>Chapter 3.2</h2>
|
||||
<div class="standard">
|
||||
Intro to Chapter 3.2
|
||||
<bookmark title="Chapter 3.2.1" level="2" ></bookmark><h3>Chapter 3.2.1</h3>
|
||||
<div class="standard">
|
||||
Contents of Chapter 3.2.1
|
||||
</div>
|
||||
<bookmark title="Chapter 3.2.2" level="2" ></bookmark><h3>Chapter 3.2.2</h3>
|
||||
<div class="standard">
|
||||
Contents of Chapter 3.2.2
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</page>
|
||||
```
|
||||
|
||||
```php
|
||||
$html2pdf = new Spipu\Html2Pdf\Html2Pdf('P','A4','en');
|
||||
$html2pdf->writeHTML($html);
|
||||
$html2pdf->createIndex('Summary', 25, 12, false, true, 1);
|
||||
$html2pdf->output();
|
||||
```
|
||||
|
||||
[back](./README.md)
|
32
html2pdf-master/doc/cert.md
Normal file
32
html2pdf-master/doc/cert.md
Normal file
@ -0,0 +1,32 @@
|
||||
# Electronic Signature
|
||||
|
||||
[back](./README.md)
|
||||
|
||||
You can add an electronic signature to the PDF, by using the following specific html TAG:
|
||||
|
||||
```
|
||||
<cert
|
||||
src="/path/to/cert.pem"
|
||||
privkey="/path/to/priv.pem"
|
||||
name="sender_name"
|
||||
location="sender_location"
|
||||
reason="sender_reason"
|
||||
contactinfo="sender_contact"
|
||||
>
|
||||
/** html **/
|
||||
</cert>
|
||||
```
|
||||
|
||||
Attribute | Description | Example 1 | Example 2
|
||||
------------|-----------------------------------|---------------------|-------------------
|
||||
src | Path to the Cert | /www/certs/my.pem | /www/certs/my.crt
|
||||
privkey | Private key of the Cert if needed | /www/certs/priv.pem | nothing
|
||||
name | Name of the Cert | My.org Cert |
|
||||
location | Country of the Cert | France |
|
||||
reason | Purpose of the Cert | Invoice validation |
|
||||
contactinfo | EMail of organisation's contact | contact@my.org |
|
||||
|
||||
/** HTML **/
|
||||
part could be any HTML formatted string, img, etc...
|
||||
|
||||
[back](./README.md)
|
48
html2pdf-master/doc/exception.md
Normal file
48
html2pdf-master/doc/exception.md
Normal file
@ -0,0 +1,48 @@
|
||||
# Exception
|
||||
|
||||
[back](./README.md)
|
||||
|
||||
## Exceptions
|
||||
|
||||
All the specific Html2Pdf exceptions are under the namespace `\Spipu\Html2Pdf\Exception`;
|
||||
|
||||
Exception|Error Code|Additional Info|Description
|
||||
---------|----------|---------------|-----------
|
||||
Html2PdfException | 0 | | Occurs for every generic error during the process
|
||||
HtmlParsingException | 1 | <ul><li>getInvalidTag</li><li>getHtmlLine</li></ul> | Occurs if the html is no valid
|
||||
ImageException | 2 | <ul><li>getImage</li></ul> | Occurs if the asked image does not exist
|
||||
LongSentenceException | 3 | <ul><li>getSentence</li><li>getWidthBox</li><li>getLength</li></ul> | Occurs is a sentence is too long and does not fit in the current box
|
||||
TableException | 4 | | Occurs if the content of a TD does not fit on only one page
|
||||
|
||||
## Exception Format
|
||||
|
||||
An exception formatter can be used to display the exceptions: `\Spipu\Html2Pdf\Exception\ExceptionFormatter`.
|
||||
|
||||
It takes the current exception as a parameter of the constructor.
|
||||
|
||||
It provides 2 methods
|
||||
|
||||
* getMessage()
|
||||
* getHtmlMessage();
|
||||
|
||||
Usage example:
|
||||
|
||||
```php
|
||||
try {
|
||||
use Spipu\Html2Pdf\Html2Pdf;
|
||||
use Spipu\Html2Pdf\Exception\Html2PdfException;
|
||||
use Spipu\Html2Pdf\Exception\ExceptionFormatter;
|
||||
|
||||
$html2pdf = new Html2Pdf('P', 'A4', 'fr');
|
||||
$html2pdf->setDefaultFont('Arial');
|
||||
$html2pdf->writeHTML($htmlContent);
|
||||
$html2pdf->output();
|
||||
} catch (Html2PdfException $e) {
|
||||
$html2pdf->clean();
|
||||
|
||||
$formatter = new ExceptionFormatter($e);
|
||||
echo $formatter->getHtmlMessage();
|
||||
}
|
||||
```
|
||||
|
||||
[back](./README.md)
|
141
html2pdf-master/doc/extension.md
Normal file
141
html2pdf-master/doc/extension.md
Normal file
@ -0,0 +1,141 @@
|
||||
# Extensions and Tags
|
||||
|
||||
[back](./README.md)
|
||||
|
||||
## Html Tags
|
||||
|
||||
All the existing tags are under the namespace `\Spipu\Html2Pdf\Tag`.
|
||||
|
||||
A tag must implement the interface `\Spipu\Html2Pdf\Tag\TagInterface`.
|
||||
|
||||
A tag can extends the abstract class `\Spipu\Html2Pdf\Tag\AbstractTag` to implement some generic methods.
|
||||
|
||||
Here is a tag example that will do nothing:
|
||||
|
||||
```php
|
||||
<?php
|
||||
namespace Example\Html2Pdf\Tag;
|
||||
|
||||
use \Spipu\Html2Pdf\Tag\AbstractTag;
|
||||
|
||||
/**
|
||||
* Tag Example
|
||||
*/
|
||||
class Example extends AbstractTag
|
||||
{
|
||||
/**
|
||||
* get the name of the tag
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'example';
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the HTML tag
|
||||
*
|
||||
* @param array $properties properties of the HTML tag
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function open($properties)
|
||||
{
|
||||
// there is nothing to do here
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the HTML tag
|
||||
*
|
||||
* @param array $properties properties of the HTML tag
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function close($properties)
|
||||
{
|
||||
// there is nothing to do here
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Then, you will be able to use the `<example>` html tag.
|
||||
|
||||
Look at all the existing tags in the `/src/Tag` folder to see examples.
|
||||
|
||||
## Extensions
|
||||
|
||||
In order to add your new tags to Html2Pdf, you must a extension.
|
||||
|
||||
An extension must implement the interface `\Spipu\Html2Pdf\Extension\ExtensionInterface`.
|
||||
|
||||
You must implement the `getTags` method that will return a list of tag objects.
|
||||
|
||||
```php
|
||||
<?php
|
||||
/**
|
||||
* Extension Example
|
||||
*/
|
||||
namespace Example\Html2Pdf\Extension;
|
||||
|
||||
use \Spipu\Html2Pdf\Extension\ExtensionInterface;
|
||||
|
||||
/**
|
||||
* Class MyExtension
|
||||
*/
|
||||
class MyExtension implements ExtensionInterface
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $tagDefinitions = array();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'example_extension';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getTags()
|
||||
{
|
||||
if (empty($this->tagDefinitions)) {
|
||||
$this->tagDefinitions = array(
|
||||
new \Example\Html2Pdf\Tag\Example(),
|
||||
new \Example\Html2Pdf\Tag\Other(),
|
||||
);
|
||||
}
|
||||
|
||||
return $this->tagDefinitions;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Then, you can add your extension to Html2Pdf with the following method:
|
||||
|
||||
```php
|
||||
$html2pdf->addExtension(new \Example\Html2Pdf\Extension\MyExtension());
|
||||
```
|
||||
|
||||
The following core extensions are automatically added to Html2pdf:
|
||||
|
||||
* `\Spipu\Html2Pdf\Extension\Core\HtmlExtension`
|
||||
* `\Spipu\Html2Pdf\Extension\Core\SvgExtension`
|
||||
|
||||
It contains all the native tags.
|
||||
|
||||
## Overriding
|
||||
|
||||
If an extension has the same name that an already added extension, it will replace the first one.
|
||||
|
||||
If tag has the same name that an already added tag throw an extension, it will replace the first one.
|
||||
|
||||
[back](./README.md)
|
44
html2pdf-master/doc/font.md
Normal file
44
html2pdf-master/doc/font.md
Normal file
@ -0,0 +1,44 @@
|
||||
# Font
|
||||
|
||||
[back](./README.md)
|
||||
|
||||
## Creating new Font
|
||||
|
||||
To create new font, you should use this tutorial from TCPDF:
|
||||
|
||||
https://tcpdf.org/docs/fonts/
|
||||
|
||||
## Adding new font
|
||||
|
||||
To use this new font, you must add it to Html2Pdf, by using the following method:
|
||||
|
||||
```php
|
||||
$html2pdf->addFont($family, $style, $file);
|
||||
```
|
||||
|
||||
The parameters are:
|
||||
|
||||
Parameter| Default | Description
|
||||
---------|---------|-------------
|
||||
$family | | Font family. The name can be chosen arbitrarily. If it is a standard family name, it will override the corresponding font.
|
||||
$style | | Font style. Possible values are (case insensitive):<ul><li>empty string: regular (default)</li><li>B: bold</li><li>I: italic</li><li>BI or IB: bold italic</li></ul>
|
||||
$file | | The font definition file. By default, the name is built from the family and style, in lower case with no spaces.
|
||||
|
||||
If you want to add font for normal and for bold style, you must call the `addFont` method twice, one for each font file.
|
||||
|
||||
**WARNING**:
|
||||
In 4em parameter constructor of Html2pdf, you must specify whether you use a Unicode font (true) or an old font (false).
|
||||
|
||||
## Using new font
|
||||
|
||||
You have just to se the new font family name in your css.
|
||||
|
||||
## Setting the default font
|
||||
|
||||
You can set the default font to use with the following method:
|
||||
|
||||
```php
|
||||
$html2pdf->setDefaultFont($default);
|
||||
```
|
||||
|
||||
[back](./README.md)
|
64
html2pdf-master/doc/install.md
Normal file
64
html2pdf-master/doc/install.md
Normal file
@ -0,0 +1,64 @@
|
||||
# How to Install Html2Pdf
|
||||
|
||||
[back](./README.md)
|
||||
|
||||
## Composer and Packagist
|
||||
|
||||
You must use Composer to install Html2Pdf.
|
||||
|
||||
If you do not know what is Composer, you are a few years late...
|
||||
|
||||
It is used by all the modern PHP applications (Magento2, Drupal, EasyPlatform, Symfony, ...).
|
||||
|
||||
You can read all the pages on https://getcomposer.org/doc/
|
||||
|
||||
You can find all the available packages on https://packagist.org/
|
||||
|
||||
For example, you can find Html2Pdf: https://packagist.org/packages/spipu/html2pdf
|
||||
|
||||
You have to commit the `composer.json` and `composer.lock` files, but **never** commit the `vendor` folder.
|
||||
|
||||
If you do not understand why, it is because you have not read the Composer documentation...
|
||||
|
||||
## Install
|
||||
|
||||
You have just to launch the following command on the root folder of your project:
|
||||
|
||||
```bash
|
||||
composer require spipu/html2pdf
|
||||
```
|
||||
|
||||
### First Test
|
||||
|
||||
Here is a HelloWorld example, that you can put on the root folder of your project.
|
||||
|
||||
```php
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
|
||||
use Spipu\Html2Pdf\Html2Pdf;
|
||||
|
||||
$html2pdf = new Html2Pdf();
|
||||
$html2pdf->writeHTML('<h1>HelloWorld</h1>This is my first test');
|
||||
$html2pdf->output();
|
||||
```
|
||||
|
||||
Html2Pdf use the PSR-4 autoloader of Composer. You have just to require it. Never require manually the classes, it will not work at all. You must use the Composer functionnalities.
|
||||
|
||||
Then, you have just to use the main class `Spipu\Html2Pdf\Html2Pdf`, with the 2 main methods `writeHTML` and `output`.
|
||||
|
||||
### And on production ?
|
||||
|
||||
You have **not** to install composer on your production server.
|
||||
|
||||
You have to install composer **only** on your dev environement. Composer is a dev tool.
|
||||
|
||||
To deliver you app on a server, you have to (on you dev environement) :
|
||||
|
||||
* Git clone the tag/branch that you want to deliver
|
||||
* Launch the command `composer install --no-dev`
|
||||
* Remove the useless files (like the `.git` folder)
|
||||
* Zip all
|
||||
|
||||
That's all, you have a beautifull package that can be deliver on a server !
|
||||
|
||||
[back](./README.md)
|
65
html2pdf-master/doc/methods.md
Normal file
65
html2pdf-master/doc/methods.md
Normal file
@ -0,0 +1,65 @@
|
||||
# Useful Methods
|
||||
|
||||
[back](./README.md)
|
||||
|
||||
## Image Must Exist
|
||||
|
||||
By default, if you try to use an image that Html2Pdf can not read, it will throw an `ImageException`.
|
||||
|
||||
You can disable this test with the following method:
|
||||
|
||||
```php
|
||||
$html2pdf->setTestIsImage(false);
|
||||
```
|
||||
|
||||
If you disable the test, and if an image does not exist, it will display a 16x16 grey square instead.
|
||||
|
||||
## FallBack Image
|
||||
|
||||
If you disable the "Image Must Exist" test, you can specify a fallback image with the following method:
|
||||
|
||||
```php
|
||||
$html2pdf->setFallbackImage($imageFilename);
|
||||
```
|
||||
|
||||
## Can not split TD content
|
||||
|
||||
By default, the content of a TD should not exceed one page.
|
||||
|
||||
You can disable this protection with the following method:
|
||||
|
||||
```php
|
||||
$html2pdf->setTestTdInOnePage(false);
|
||||
```
|
||||
|
||||
**WARNING**:
|
||||
If you disable this test, you may have big layouts problems on tables in multiple columns.
|
||||
|
||||
Rather than disabling this test it is better to break the TD content in smaller ones.
|
||||
|
||||
**We do not support the consequencies of disable this test.**
|
||||
|
||||
## Debug Mode
|
||||
|
||||
You can enable a debug mode by using the following method:
|
||||
|
||||
```php
|
||||
$html2pdf->setModeDebug();
|
||||
```
|
||||
|
||||
You can specify your own debugger. It must implement `\Spipu\Html2Pdf\Debug\DebugInterface`.
|
||||
|
||||
```php
|
||||
$debug = new \Spipu\Html2Pdf\Debug\Debug();
|
||||
$html2pdf->setModeDebug($debug);
|
||||
```
|
||||
## Version
|
||||
|
||||
You can get the current Html2Pdf version with the following methods:
|
||||
|
||||
```php
|
||||
$html2pdf->getVersion();
|
||||
$html2pdf->getVersionAsArray();
|
||||
```
|
||||
|
||||
[back](./README.md)
|
50
html2pdf-master/doc/output.md
Normal file
50
html2pdf-master/doc/output.md
Normal file
@ -0,0 +1,50 @@
|
||||
# Output
|
||||
|
||||
[back](./README.md)
|
||||
|
||||
The main method to use is `output`.
|
||||
|
||||
It takes two not required parameters.
|
||||
|
||||
## Parameters
|
||||
|
||||
Parameter| Default | Description
|
||||
---------|---------|-------------
|
||||
$name | document.pdf | The name of the file when saved. Note that special characters are removed and blanks characters are replaced with the underscore character.
|
||||
$dest | I | Destination where to send the document. It can take one of the following values:<ul><li>I: send the file inline to the browser (default). The plug-in is used if available. The name given by name is used when one selects the "Save as" option on the link generating the PDF.</li><li>D: send to the browser and force a file download with the name given by name.</li><li>F: save to a local server file with the name given by name.</li><li>S: return the document as a string (name is ignored).</li><li>FI: equivalent to F + I option</li><li>FD: equivalent to F + D option</li><li>E: return the document as base64 mime multi-part email attachment (RFC 2045)</li></ul>
|
||||
|
||||
## Examples
|
||||
|
||||
### Send PDF to browser without specifying a name
|
||||
|
||||
```php
|
||||
$html2pdf->output();
|
||||
```
|
||||
|
||||
### Send the PDF document in browser with a specific name
|
||||
|
||||
```php
|
||||
$html2pdf->output('my_doc.pdf');
|
||||
```
|
||||
|
||||
### Forcing the download of PDF via web browser, with a specific name
|
||||
|
||||
```php
|
||||
$html2pdf->output('my_doc.pdf', 'D');
|
||||
```
|
||||
|
||||
### Write the contents of a PDF file on the server
|
||||
|
||||
```php
|
||||
$html2pdf->output('/absolute/path/file_xxxx.pdf', 'F');
|
||||
```
|
||||
|
||||
### Retrieve the contents of the PDF and then do whatever you want
|
||||
|
||||
```php
|
||||
$pdfContent = $html2pdf->output('my_doc.pdf', 'S');
|
||||
```
|
||||
|
||||
Then, you can send it by email, using a Bin Attachment document.
|
||||
|
||||
[back](./README.md)
|
138
html2pdf-master/doc/page.md
Normal file
138
html2pdf-master/doc/page.md
Normal file
@ -0,0 +1,138 @@
|
||||
# Page Management
|
||||
|
||||
[back](./README.md)
|
||||
|
||||
To facilitate the layout, three specific tags have been added:
|
||||
|
||||
* `<page>`
|
||||
* `<page_header>`
|
||||
* `<page_footer>`
|
||||
|
||||
They must be used as follow:
|
||||
|
||||
```html
|
||||
<page>
|
||||
<page_header>
|
||||
...
|
||||
</page_header>
|
||||
<page_footer>
|
||||
...
|
||||
</page_footer>
|
||||
...
|
||||
</page>
|
||||
```
|
||||
|
||||
You **must not** use `<body>` and `<html>` tags.
|
||||
|
||||
## Page tag
|
||||
|
||||
### Attributes
|
||||
|
||||
You can use the main following attributes:
|
||||
|
||||
Attribute| Default | Description
|
||||
---------|---------|-------------
|
||||
pageset | new | Specify if we want to use the previous page definition (old) or a new one (new)
|
||||
pagegroup | old | Specify if we are in the same page group (old) or in a new one (new)
|
||||
hideheader | | comma-separate page numbers on which we want to hide the header
|
||||
hidefooter | | comma-separate page numbers on which we want to hide the footer
|
||||
orientation | | Portrait (P) or Lanscape (L). By default, the orientation specified in the Html2Pdf constructor
|
||||
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
|
||||
style | | css style
|
||||
class | | css class
|
||||
|
||||
You can use the following attributes to manage page margin:
|
||||
|
||||
Attribute| Default | Description
|
||||
---------|---------|-------------
|
||||
backtop | 0 | value with unit (mm, px, pt, % )
|
||||
backbottom | 0 | value with unit (mm, px, pt, % )
|
||||
backleft | 0 | value with unit (mm, px, pt, % )
|
||||
backright | 0 | value with unit (mm, px, pt, % )
|
||||
|
||||
You can use the following attributes to manage page background:
|
||||
|
||||
Attribute| Default | Description
|
||||
---------|---------|-------------
|
||||
backcolor | transparent | css color value
|
||||
backimg | | url of the image to use
|
||||
backimgx | center | x position of the image on the page background: left / center / right / value with unit (mm, px, pt, % )
|
||||
backimgy | middle | y position of the image on the page background: top / middle / bottom / value with unit (mm, px, pt, % )
|
||||
backimgw | 100% | width on the image on the page background: value with unit (mm, px, pt, % )
|
||||
|
||||
You can add a light footer by using the attribute footer. It takes coma-separated values:
|
||||
|
||||
Value| Description
|
||||
-----|-------------
|
||||
page | display the current page
|
||||
date | display the generation date
|
||||
time | display the generation time
|
||||
form | display a disclamer about form compatibility
|
||||
|
||||
### explanation
|
||||
|
||||
It allows to define, for the entire html code included within the layout :
|
||||
|
||||
* margins left, right, top, bottom (backleft, backright, backtop, backbottom)
|
||||
* background image, with its position and size (backimg, backimgx, backimgy, backimgw)
|
||||
* the background color (backcolor)
|
||||
* orientation (orientation) and format (format)
|
||||
* simple automatic footer (footer)
|
||||
* a header and a footer complex HTML (using tags page_header and page_footer).
|
||||
|
||||
It does not limit it-self to one final page of the PDF, but to a set of pages.
|
||||
|
||||
Any HTML code will be included automatically within the same layout.
|
||||
|
||||
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.
|
||||
|
||||
## Page Header tag
|
||||
|
||||
Its allows you to use complex HTML as the header of the current page.
|
||||
|
||||
Its definition must necessarily be located just after the opening of the `<page>` tag.
|
||||
|
||||
It can contain any valid HTML.
|
||||
|
||||
It is **REQUIRED** to specify the top margin, using the `backtop` attribute on the `<page>` tag.
|
||||
|
||||
You can use ̀`css` and `class` attribute on this specific tag.
|
||||
|
||||
## Page Footer tag
|
||||
|
||||
Its allows you to use complex HTML as the header of the current page.
|
||||
|
||||
Its definition must necessarily be located just after the opening of the `<page>` tag.
|
||||
|
||||
It can contain any valid HTML.
|
||||
|
||||
It is **REQUIRED** to specify the top margin, using the `backtop` attribute on the `<page>` tag.
|
||||
|
||||
You can use `css` and `class` attribute on this specific tag.
|
||||
|
||||
## Margin Explanation
|
||||
|
||||
Here's a little explanation of different margins:
|
||||
|
||||
```html
|
||||
<page backtop="7mm" backbottom="7mm" backleft="10mm" backright="10mm">
|
||||
<page_header>
|
||||
Page Header
|
||||
</page_header>
|
||||
<page_footer>
|
||||
Page Footer
|
||||
</page_footer>
|
||||
|
||||
Page Content
|
||||
</page>
|
||||
```
|
||||
|
||||
```php
|
||||
$pdf = new \Spipu\Html2Pdf\Html2Pdf('P','A4','en', false, 'UTF-8', array(mL, mT, mR, mB));
|
||||
$pdf->writeHTML($htmlContent);
|
||||
$pdf->Output();
|
||||
```
|
||||
|
||||

|
||||
|
||||
[back](./README.md)
|
BIN
html2pdf-master/doc/res/margins.jpg
Normal file
BIN
html2pdf-master/doc/res/margins.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 95 KiB |
53
html2pdf-master/doc/svg.md
Normal file
53
html2pdf-master/doc/svg.md
Normal file
@ -0,0 +1,53 @@
|
||||
# SVG tags
|
||||
|
||||
[back](./README.md)
|
||||
|
||||
## Tag draw
|
||||
|
||||
A new html tag `<draw>` has been implemented.
|
||||
|
||||
It allows to insert a SVG image in your PDF.
|
||||
|
||||
The only allowed attributes are `css` and `class`.
|
||||
|
||||
Example:
|
||||
|
||||
```html
|
||||
<page>
|
||||
<draw style="margin: auto; width:150mm; height:100mm; background: #000000; border: solid 0.5mm #777777;">
|
||||
<line style="stroke:#FF0000; stroke-width:1mm" x1="10mm" y1="10mm" x2="140mm" y2="10mm" >
|
||||
<rect style="stroke:#770077; stroke-width:1mm; fill:#008888" x="15%" y="15%" w="70%" h="70%">
|
||||
<ellipse style="stroke:#000077; stroke-width:1mm; fill:#888800" cx="50%" cy="50%" rx="30%" ry="30%">
|
||||
<circle style="stroke:#0000AA; stroke-width:1mm; fill:#AAAA00" cx="50%" cy="50%" r="15%">
|
||||
</draw><br>
|
||||
<draw style="margin: auto; width:150mm; height:100mm; background: #000000; border: solid 0.5mm #777777;">
|
||||
<path style="fill:#AAAA00; stroke:#0000AA; stroke-width:1mm" d="M20mm,10mm H130mm A10mm,10mm 0,0,0 140mm,20mm V80mm A10mm,10mm 0,0,0 130mm,90mm H20mm A10mm,10mm 0,0,0 10mm,80mm V20mm A10mm,10mm 0,0,0 20mm,10mm">
|
||||
<path style="fill:#770000; stroke:#AA0033; stroke-width:0.5mm" d="M 20mm,40mm a16mm,8mm 0,0,0 16mm,8mm" />
|
||||
<path style="fill:#770000; stroke:#00AA33; stroke-width:0.5mm" d="M 20mm,40mm l16mm,8mm" />
|
||||
<path style="fill:#770000; stroke:#AA0033; stroke-width:0.5mm" d="M 40mm,40mm a16mm,8mm 0,0,1 16mm,8mm" />
|
||||
<path style="fill:#770000; stroke:#00AA33; stroke-width:0.5mm" d="M 40mm,40mm l16mm,8mm" />
|
||||
<path style="fill:#770000; stroke:#AA0033; stroke-width:0.5mm" d="M 80mm,40mm a16mm,8mm 0,1,0 16mm,8mm" />
|
||||
<path style="fill:#770000; stroke:#00AA33; stroke-width:0.5mm" d="M 80mm,40mm l16mm,8mm" />
|
||||
<path style="fill:#770000; stroke:#AA0033; stroke-width:0.5mm" d="M100mm,40mm a16mm,8mm 0,1,1 16mm,8mm" />
|
||||
<path style="fill:#770000; stroke:#00AA33; stroke-width:0.5mm" d="M100mm,40mm l16mm,8mm" />
|
||||
</draw><br>
|
||||
<br>
|
||||
</page>
|
||||
```
|
||||
|
||||
## Allowed SVG tags
|
||||
|
||||
* LINE
|
||||
* RECT
|
||||
* CIRCLE
|
||||
* ELLIPSE
|
||||
* PATH
|
||||
* POLYGON
|
||||
* POLYLINE
|
||||
* G
|
||||
|
||||
## SVG Documentation
|
||||
|
||||
See http://www.w3.org/TR/SVG11/expanded-toc.html
|
||||
|
||||
[back](./README.md)
|
62
html2pdf-master/doc/tcpdf_methods.md
Normal file
62
html2pdf-master/doc/tcpdf_methods.md
Normal file
@ -0,0 +1,62 @@
|
||||
# TCPDF Methods
|
||||
|
||||
[back](./README.md)
|
||||
|
||||
All the TCPDF methods can be used, by using the `pdf` property:
|
||||
|
||||
```php
|
||||
$html2pdf->pdf->...
|
||||
```
|
||||
|
||||
## Display Mode
|
||||
|
||||
You can change how your PDF document will be displayed, with the `SetDisplayMode` method:
|
||||
|
||||
```php
|
||||
$html2pdf = new \Spipu\Html2Pdf\Html2Pdf('P', 'A4', 'en');
|
||||
$html2pdf->pdf->SetDisplayMode('fullpage');
|
||||
$html2pdf->writeHTML($htmlContent);
|
||||
$html2pdf->output();
|
||||
```
|
||||
|
||||
The parameters are:
|
||||
|
||||
Parameter| Default | Description
|
||||
---------|---------|-------------
|
||||
$zoom | | The zoom to use. It can be one of the following string values or a number indicating the zooming factor to use. <ul><li>fullpage: displays the entire page on screen </li><li>fullwidth: uses maximum width of window</li><li>real: uses real size (equivalent to 100% zoom)</li><li>default: uses viewer default mode</li></ul>
|
||||
$layout | SinglePage | The page layout. Possible values are:<ul><li>SinglePage Display one page at a time</li><li>OneColumn Display the pages in one column</li><li>TwoColumnLeft Display the pages in two columns, with odd-numbered pages on the left</li><li>TwoColumnRight Display the pages in two columns, with odd-numbered pages on the right</li><li>TwoPageLeft (PDF 1.5) Display the pages two at a time, with odd-numbered pages on the left</li><li>TwoPageRight (PDF 1.5) Display the pages two at a time, with odd-numbered pages on the right</li></ul>
|
||||
$mode | UseNone | A name object specifying how the document should be displayed when opened:<ul><li>UseNone Neither document outline nor thumbnail images visible</li><li>UseOutlines Document outline visible</li><li>UseThumbs Thumbnail images visible</li><li>FullScreen Full-screen mode, with no menu bar, window controls, or any other window visible</li><li>UseOC (PDF 1.5) Optional content group panel visible</li><li>UseAttachments (PDF 1.6) Attachments panel visible</li></ul>
|
||||
|
||||
## Document Information
|
||||
|
||||
You can change the document information, with the following methods:
|
||||
|
||||
```php
|
||||
$html2pdf = new \Spipu\Html2Pdf\Html2Pdf('P', 'A4', 'en');
|
||||
$html2pdf->pdf->SetAuthor('LAST-NAME Frist-Name');
|
||||
$html2pdf->pdf->SetTitle('My Pdf Document');
|
||||
$html2pdf->pdf->SetSubject('it will be about something important');
|
||||
$html2pdf->pdf->SetKeywords('example, keywords, others');
|
||||
$html2pdf->writeHTML($htmlContent);
|
||||
$html2pdf->output();
|
||||
```
|
||||
|
||||
## Document Protection
|
||||
|
||||
You can protect your PDF document, with the `setProtection` method:
|
||||
|
||||
```php
|
||||
$html2pdf->pdf->SetProtection($permissions, $userPass, $ownerPass, $mode, $pubkeys);
|
||||
```
|
||||
|
||||
The parameters are:
|
||||
|
||||
Parameter| Default | Description
|
||||
---------|---------|-------------
|
||||
$permissions | | the set of permissions (specify the ones you want to block):<ul><li>print : Print the document;</li><li>modify : Modify the contents of the document by operations other than those controlled by 'fill-forms', 'extract' and 'assemble';</li><li>copy : Copy or otherwise extract text and graphics from the document;</li><li>annot-forms : Add or modify text annotations, fill in interactive form fields, and, if 'modify' is also set, create or modify interactive form fields (including signature fields);</li><li>fill-forms : Fill in existing interactive form fields (including signature fields), even if 'annot-forms' is not specified;</li><li>extract : Extract text and graphics (in support of accessibility to users with disabilities or for other purposes);</li><li>assemble : Assemble the document (insert, rotate, or delete pages and create bookmarks or thumbnail images), even if 'modify' is not set;</li><li>print-high : Print the document to a representation from which a faithful digital copy of the PDF content could be generated. When this is not set, printing is limited to a low-level representation of the appearance, possibly of degraded quality.</li><li>owner : (inverted logic - only for public-key) when set permits change of encryption and enables all other permissions.</li></ul>
|
||||
$userPass | | user password. Empty by default.
|
||||
$ownerPass | null | owner password. If not specified, a random value is used.
|
||||
$mode | 0 | encryption strength: 0 = RC4 40 bit; 1 = RC4 128 bit; 2 = AES 128 bit; 3 = AES 256 bit.
|
||||
$pubkeys | null| array of recipients containing public-key certificates ('c') and permissions ('p'). For example: array(array('c' => 'file://../examples/data/cert/tcpdf.crt', 'p' => array('print')))
|
||||
|
||||
[back](./README.md)
|
Reference in New Issue
Block a user