### Generate Basic HTML to PDF with Html2Pdf (PHP)
Source: https://github.com/spipu/html2pdf/blob/master/doc/install.md
A 'HelloWorld' PHP example demonstrating the basic usage of Html2Pdf. It initializes the Html2Pdf class, writes simple HTML content, and outputs it as a PDF. This snippet relies on Composer's autoloader for class loading.
```php
require __DIR__.'/vendor/autoload.php';
use Spipu\Html2Pdf\Html2Pdf;
$html2pdf = new Html2Pdf();
$html2pdf->writeHTML('
HelloWorld
This is my first test');
$html2pdf->output();
```
--------------------------------
### Install Html2Pdf with Composer
Source: https://github.com/spipu/html2pdf/blob/master/doc/install.md
This command installs the Html2Pdf library into your project using Composer, the dependency manager for PHP. It is the recommended and supported method for installation.
```bash
composer require spipu/html2pdf
```
--------------------------------
### Complete Html2Pdf Hello World Example
Source: https://github.com/spipu/html2pdf/blob/master/doc/basic.md
A full, runnable example demonstrating the complete workflow of creating an Html2Pdf instance, adding HTML content using `writeHTML`, and outputting the generated PDF using `output`.
```php
$html2pdf = new \Spipu\Html2Pdf\Html2Pdf('P', 'A4', 'en');
$html2pdf->writeHTML('HelloWorld
This is my first page');
$html2pdf->output();
```
--------------------------------
### HTML2PDF Page Margin Configuration Example
Source: https://github.com/spipu/html2pdf/blob/master/doc/page.md
This example demonstrates how to define page margins using attributes on the tag in HTML and how to initialize the Html2Pdf object in PHP with default margins. It shows a complete setup for a page with a header, footer, and content, along with the corresponding PHP code to render it.
```html
Page Header
Page Footer
Page Content
```
```php
$pdf = new \Spipu\Html2Pdf\Html2Pdf('P','A4','en', false, 'UTF-8', array(mL, mT, mR, mB));
$pdf->writeHTML($htmlContent);
$pdf->Output();
```
--------------------------------
### HTML and PHP Example: Automatic Index Generation
Source: https://github.com/spipu/html2pdf/blob/master/doc/bookmark.md
A comprehensive example demonstrating the integration of HTML bookmarks with PHP to generate an automatic index. The HTML part includes page headers, footers, and nested bookmarks across multiple pages. The PHP part initializes html2pdf, writes the HTML, calls createIndex to generate the summary, and outputs the PDF. This example specifically shows how to place the index on the last page.
```html
Chapter 1
Contents of Chapter 1
Chapter 2
Intro to Chapter 2
Chapter 2.1
Contents of Chapter 2.1
Chapter 2.2
Contents of Chapter 2.2
Chapter 2.3
Contents of Chapter 2.3
Chapter 3
Intro to Chapter 3
Chapter 3.1
Contents of Chapter 3.1
Chapter 3.2
Intro to Chapter 3.2
Chapter 3.2.1
Contents of Chapter 3.2.1
Chapter 3.2.2
Contents of Chapter 3.2.2
```
```php
$html2pdf = new Spipu\Html2Pdf\Html2Pdf('P','A4','en');
$html2pdf->writeHTML($html);
$html2pdf->createIndex('Summary', 25, 12, true, true);
$html2pdf->output();
```
--------------------------------
### HTML Bookmark Tag Example
Source: https://github.com/spipu/html2pdf/blob/master/doc/bookmark.md
Provides an example of the tag used to define an automatic bookmark within HTML content. This tag is crucial for structuring documents for index generation.
```html
```
--------------------------------
### Instantiate Html2Pdf with Basic Parameters
Source: https://github.com/spipu/html2pdf/blob/master/doc/basic.md
Example demonstrating how to create a new instance of the `\Spipu\Html2Pdf\Html2Pdf` class using the most common parameters: page orientation, format, and language.
```php
$html2pdf = new \Spipu\Html2Pdf\Html2Pdf('P', 'A4', 'en');
```
--------------------------------
### Implement a Custom Extension for Html2Pdf
Source: https://github.com/spipu/html2pdf/blob/master/doc/extension.md
This PHP example illustrates how to create an extension to bundle custom tags for Html2Pdf. The extension class implements ExtensionInterface and defines a getTags method that returns an array of tag objects, making them available to the Html2Pdf instance.
```php
tagDefinitions)) {
$this->tagDefinitions = array(
new \Example\Html2Pdf\Tag\Example(),
new \Example\Html2Pdf\Tag\Other()
);
}
return $this->tagDefinitions;
}
}
```
--------------------------------
### Get Html2Pdf Version Information
Source: https://github.com/spipu/html2pdf/blob/master/doc/methods.md
Retrieve the current version of the Html2Pdf library. You can get the version as a string or as an array containing detailed version components.
```php
$html2pdf->getVersion();
$html2pdf->getVersionAsArray();
```
--------------------------------
### Handling Html2Pdf Exceptions in PHP
Source: https://github.com/spipu/html2pdf/blob/master/doc/exception.md
This PHP example demonstrates how to use a try-catch block to handle exceptions thrown by the Html2Pdf library. It specifically catches Html2PdfException and utilizes the ExceptionFormatter class to display a user-friendly HTML error message.
```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();
}
```
--------------------------------
### Define a Custom HTML Tag for Html2Pdf
Source: https://github.com/spipu/html2pdf/blob/master/doc/extension.md
This PHP example demonstrates how to create a custom HTML tag for Html2Pdf. It shows a class implementing TagInterface (or extending AbstractTag) with getName, open, and close methods, allowing the tag to be recognized and processed by Html2Pdf.
```php
Tag
Source: https://github.com/spipu/html2pdf/blob/master/doc/svg.md
This HTML snippet demonstrates how to use the custom tag to embed different SVG shapes like lines, rectangles, ellipses, circles, and paths within a PDF. The tag supports `style` and `class` attributes for styling. The example shows two blocks, one with basic shapes and another with complex path definitions.
```HTML
```
--------------------------------
### HTML Tag for Electronic Signature in PDF
Source: https://github.com/spipu/html2pdf/blob/master/doc/cert.md
Example of the HTML tag used to embed an electronic signature into a PDF. It specifies attributes for certificate source, private key, sender details, and allows any HTML content within the tag, indicated by the '/** html **/' placeholder.
```HTML
/** html **/
```
--------------------------------
### Html2Pdf Class Constructor Definition
Source: https://github.com/spipu/html2pdf/blob/master/doc/basic.md
Documents the constructor of the `\Spipu\Html2Pdf\Html2Pdf` class, detailing all available parameters, their types, default values, and descriptions for configuring PDF generation.
```APIDOC
\Spipu\Html2Pdf\Html2Pdf::__construct(
$orientation: string = 'P', // Default page orientation (P: portrait, L: landscape)
$format: string|array = 'A4', // Default page format (e.g., 'A4', or [width, height] in mm)
$lang: string = 'fr', // Language for minor translations
$unicode: bool = true, // Indicates if input HTML string is unicode
$encoding: string = 'UTF-8', // Charset encoding of the input HTML string
$margins: array = [5, 5, 5, 8], // Main page margins (left, top, right, bottom) in mm
$pdfa: bool = false // If TRUE, sets the document to PDF/A mode
)
```
--------------------------------
### Output Generated PDF to Browser
Source: https://github.com/spipu/html2pdf/blob/master/doc/basic.md
Shows how to use the `output` method without parameters to send the generated PDF file directly to the user's browser for display. This is the simplest way to present the PDF.
```php
$html2pdf->output();
```
--------------------------------
### Generate PDF with Automatic Index using PHP HTML2PDF
Source: https://github.com/spipu/html2pdf/blob/master/doc/bookmark.md
This PHP snippet demonstrates how to use the Spipu\Html2Pdf library to convert HTML content into a PDF document. It initializes the PDF object with specific page settings, writes the provided HTML content, and then generates an automatic index (table of contents) titled 'Summary' on page 1. Finally, it outputs the generated PDF to the browser or file.
```php
$html2pdf = new Spipu\Html2Pdf\Html2Pdf('P','A4','en');
$html2pdf->writeHTML($html);
$html2pdf->createIndex('Summary', 25, 12, false, true, 1);
$html2pdf->output();
```
--------------------------------
### Html2Pdf Configuration Methods
Source: https://github.com/spipu/html2pdf/blob/master/doc/README.md
Documentation for methods used to configure Html2Pdf behavior, including enabling or disabling specific tests related to image existence and table cell content fitting on a single page.
```APIDOC
setTestIsImage(boolean):
Description: Tests that images referenced in the HTML must exist.
setTestTdInOnePage(boolean):
Description: Tests that the contents of table data (TD) cells fit on a single page.
```
--------------------------------
### HTML2PDF Output Method Parameters
Source: https://github.com/spipu/html2pdf/blob/master/doc/output.md
Details the parameters for the `output` method of the HTML2PDF library, including their default values and descriptions of their functionality and possible destination values.
```APIDOC
Method: output($name: string, $dest: string)
Parameters:
$name:
Default: document.pdf
Description: The name of the file when saved. Special characters are removed and blanks are replaced with underscores.
$dest:
Default: I
Description: Destination where to send the document. Possible values:
I: Send the file inline to the browser (default). Plugin used if available. Name used for 'Save as' option.
D: Send to the browser and force a file download with the given name.
F: Save to a local server file with the given name.
S: Return the document as a string (name is ignored).
FI: Equivalent to F + I option.
FD: Equivalent to F + D option.
E: Return the document as base64 mime multi-part email attachment (RFC 2045).
```
--------------------------------
### Html2Pdf::output Method Definition
Source: https://github.com/spipu/html2pdf/blob/master/doc/basic.md
Documents the `output` method of the `\Spipu\Html2Pdf\Html2Pdf` class, which generates and outputs the PDF file. It takes two optional parameters for specifying the filename and destination (e.g., inline display, download, save to file, return as string).
```APIDOC
\Spipu\Html2Pdf\Html2Pdf::output(string $name = null, string $dest = 'I')
```
--------------------------------
### QR Code Tag Attributes Reference
Source: https://github.com/spipu/html2pdf/blob/master/doc/barcode.md
Detailed API documentation for the attributes of the `` HTML tag. It describes each attribute's purpose, default value, and usage, covering the value to encode, error correction level (ec), and styling options.
```APIDOC
qrcode tag attributes:
value: string
Default:
Description: value to convert into barcode
ec: string
Default: H
Description: level of error correction (L, M, Q, H)
style: string
Default:
Description: sets the width, color, background-color, and border of the qrcode
```
--------------------------------
### Retrieve PDF content as a string (PHP)
Source: https://github.com/spipu/html2pdf/blob/master/doc/output.md
Demonstrates how to retrieve the entire content of the generated PDF document as a string. This allows for further processing, such as sending it via email as a binary attachment, as the name parameter is ignored.
```php
$pdfContent = $html2pdf->output('my_doc.pdf', 'S');
```
--------------------------------
### Send PDF to browser without specifying a name (PHP)
Source: https://github.com/spipu/html2pdf/blob/master/doc/output.md
Demonstrates how to generate and send a PDF document directly to the browser using the `output` method without providing a specific filename. The browser will typically use a default name or prompt the user.
```php
$html2pdf->output();
```
--------------------------------
### 2D Barcode Types Reference
Source: https://github.com/spipu/html2pdf/blob/master/doc/barcode.md
List of supported 2D barcode types for the `type` attribute of the `` tag. This includes common 2D formats like DATAMATRIX, PDF417, and QRCODE, along with raw modes for advanced usage.
```APIDOC
2D barcode types:
DATAMATRIX: DATAMATRIX (ISO/IEC 16022)
PDF417: PDF417 (ISO/IEC 15438:2006)
QRCODE: QR-CODE
RAW: RAW MODE
RAW2: RAW MODE
```
--------------------------------
### Append HTML Content with Multiple writeHTML Calls
Source: https://github.com/spipu/html2pdf/blob/master/doc/basic.md
Shows how to call `writeHTML` multiple times to append content to the current page. This approach is useful for managing memory when converting large HTML strings by processing them in chunks.
```php
$html2pdf->writeHTML('HelloWorld
This is my first text');
$html2pdf->writeHTML('HelloWorld
This is my second text');
```
--------------------------------
### Force PDF download via browser with specific name (PHP)
Source: https://github.com/spipu/html2pdf/blob/master/doc/output.md
Shows how to force the browser to download the generated PDF file with a specified name ('my_doc.pdf') instead of displaying it inline. This is achieved by setting the destination parameter to 'D'.
```php
$html2pdf->output('my_doc.pdf', 'D');
```
--------------------------------
### Write PDF content to a server file (PHP)
Source: https://github.com/spipu/html2pdf/blob/master/doc/output.md
Explains how to save the generated PDF document directly to a specified absolute path on the server's file system. The destination parameter 'F' is used for this operation.
```php
$html2pdf->output('/absolute/path/file_xxxx.pdf', 'F');
```
--------------------------------
### Barcode Tag Attributes Reference
Source: https://github.com/spipu/html2pdf/blob/master/doc/barcode.md
Detailed API documentation for the attributes of the `` HTML tag. It describes each attribute's purpose, default value, and usage, covering dimension, type, value, label, and style for customizing barcode appearance and behavior.
```APIDOC
barcode tag attributes:
dimension: string
Default: 1D
Description: create a 1D or 2D barcode
type: string
Default: C39
Description: type of barcode to use
value: string
Default: 0
Description: value to convert into barcode
label: string
Default: label
Description: indicates that the label must be present below the bar code (label) or not (none) (not required)
style: string
Default:
Description: 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)
```
--------------------------------
### Convert Single HTML String to PDF Content
Source: https://github.com/spipu/html2pdf/blob/master/doc/basic.md
Demonstrates the basic usage of the `writeHTML` method to convert a single HTML string into PDF content. This is the primary method for adding content to the PDF document.
```php
$html2pdf->writeHTML('HelloWorld
This is my first test');
```
--------------------------------
### Enable Debug Mode in Html2Pdf
Source: https://github.com/spipu/html2pdf/blob/master/doc/README.md
Activates a debug mode to display resource usage information during PDF generation. This command should be placed immediately after the Html2Pdf constructor.
```PHP
$html2pdf->setModeDebug();
```
--------------------------------
### Register a Custom Extension with Html2Pdf Instance
Source: https://github.com/spipu/html2pdf/blob/master/doc/extension.md
This PHP snippet demonstrates how to add a newly created custom extension to an existing Html2Pdf instance using the addExtension method. This step is crucial for Html2Pdf to recognize and utilize the custom tags defined within the extension.
```php
$html2pdf->addExtension(new \Example\Html2Pdf\Extension\MyExtension());
```
--------------------------------
### Set Custom Debugger in Html2Pdf
Source: https://github.com/spipu/html2pdf/blob/master/doc/methods.md
You can provide your own custom debugger implementation to Html2Pdf. The custom debugger must implement the `\Spipu\Html2Pdf\Debug\DebugInterface` interface to be compatible.
```php
$debug = new \Spipu\Html2Pdf\Debug\Debug();
$html2pdf->setModeDebug($debug);
```
--------------------------------
### Define HTML Structure for PDF with Bookmarks and Headers
Source: https://github.com/spipu/html2pdf/blob/master/doc/bookmark.md
This HTML snippet defines the layout and content for a multi-page PDF document. It includes custom CSS for styling headers, footers, and content sections. Crucially, it uses `` tags to define points for an automatic table of contents and sets up dynamic page numbering in the footer.
```html
Chapter 1
Contents of Chapter 1
Chapter 2
Intro to Chapter 2
Chapter 2.1
Contents of Chapter 2.1
Chapter 2.2
Contents of Chapter 2.2
Chapter 2.3
Contents of Chapter 2.3
Chapter 3
Intro to Chapter 3
Chapter 3.1
Contents of Chapter 3.1
Chapter 3.2
Intro to Chapter 3.2
Chapter 3.2.1
Contents of Chapter 3.2.1
Chapter 3.2.2
Contents of Chapter 3.2.2
```
--------------------------------
### PHP html2pdf->createIndex() Function API
Source: https://github.com/spipu/html2pdf/blob/master/doc/bookmark.md
Documents the createIndex method of the html2pdf library, which is used to automatically generate an index (summary) of all defined bookmarks. It details the function's parameters, their default values, and their purpose, such as setting the index title, font sizes, and placement within the document.
```APIDOC
$html2pdf->createIndex($titre, $sizeTitle, $sizeBookmark, $bookmarkTitle, $displayPage, $onPage, $fontName, $marginTop)
$title: Index title (Default: 'Index')
$sizeTitle: Font size of the index title, in mm (Default: 20)
$sizeBookmark: Font size of the index, in mm (Default: 15)
$bookmarkTitle: Add a bookmark for the index at its beginning (Default: true)
$displayPage: Display the page numbers (Default: true)
$onPage: If null, places index at end of document on a new page; otherwise, on the specified page number (Default: null)
$fontName: Font name to use; if null, uses Helvetica (Default: null)
$marginTop: Margin top to use on the index page (Default: null)
```
--------------------------------
### Accessing TCPDF Methods via Html2Pdf
Source: https://github.com/spipu/html2pdf/blob/master/doc/tcpdf_methods.md
Demonstrates the general syntax for accessing underlying TCPDF methods by using the `pdf` property of the `Html2Pdf` instance.
```php
$html2pdf->pdf->...
```
--------------------------------
### Send PDF to browser with a specific name (PHP)
Source: https://github.com/spipu/html2pdf/blob/master/doc/output.md
Illustrates how to send a generated PDF document to the browser, specifying a custom filename. The browser will use 'my_doc.pdf' when saving or displaying the file.
```php
$html2pdf->output('my_doc.pdf');
```
--------------------------------
### Convert HTML with New Page Tag
Source: https://github.com/spipu/html2pdf/blob/master/doc/basic.md
Illustrates how to use the specific `` HTML tag within the `writeHTML` method to force a new page break in the generated PDF document, allowing for multi-page content.
```php
$html2pdf->writeHTML('HelloWorld
This is my first page');
$html2pdf->writeHTML('HelloWorld
This is my second page');
```
--------------------------------
### Html2Pdf Exception Classes and Methods
Source: https://github.com/spipu/html2pdf/blob/master/doc/exception.md
This section outlines the various exception classes provided by the Html2Pdf library, detailing their purpose, error codes, and any specific methods available for retrieving additional error information. It also describes the ExceptionFormatter class and its methods for displaying exceptions.
```APIDOC
Exception Classes:
Html2PdfException:
Error Code: 0
Description: Occurs for every generic error during the process
HtmlParsingException:
Error Code: 1
Methods:
getInvalidTag(): Returns the invalid HTML tag.
getHtmlLine(): Returns the line number in the HTML where the error occurred.
Description: Occurs if the HTML is not valid.
ImageException:
Error Code: 2
Methods:
getImage(): Returns the path to the image that caused the error.
Description: Occurs if the requested image does not exist.
LongSentenceException:
Error Code: 3
Methods:
getSentence(): Returns the sentence that was too long.
getWidthBox(): Returns the width of the box.
getLength(): Returns the length of the sentence.
Description: Occurs if a sentence is too long and does not fit in the current box.
TableException:
Error Code: 4
Description: Occurs if the content of a TD does not fit on only one page.
ExceptionFormatter Class:
Namespace: \Spipu\Html2Pdf\Exception
Constructor:
Parameters:
exception: The current exception instance (e.g., Html2PdfException).
Methods:
getMessage(): Returns a string message of the exception.
getHtmlMessage(): Returns an HTML formatted message of the exception.
```
--------------------------------
### Embed QR Code in HTML
Source: https://github.com/spipu/html2pdf/blob/master/doc/barcode.md
Illustrates how to embed a QR code directly into HTML using the `` tag. It shows how to specify the value to encode, the error correction level (H), and inline CSS styling for width, background color, and foreground color.
```html
```
--------------------------------
### APIDOC: Tag Attributes for Electronic Signature
Source: https://github.com/spipu/html2pdf/blob/master/doc/cert.md
Detailed documentation of the attributes available for the HTML tag, used for configuring electronic signatures in generated PDFs. This includes paths to certificate files and metadata about the signatory.
```APIDOC
Tag Attributes:
src:
Description: Path to the Cert
Type: string (path)
Example: /www/certs/my.pem
privkey:
Description: Private key of the Cert if needed
Type: string (path)
Example: /www/certs/priv.pem
name:
Description: Name of the Cert
Type: string
Example: My.org Cert
location:
Description: Country of the Cert
Type: string
Example: France
reason:
Description: Purpose of the Cert
Type: string
Example: Invoice validation
contactinfo:
Description: EMail of organisation's contact
Type: string
Example: contact@my.org
```
--------------------------------
### 1D Barcode Types Reference
Source: https://github.com/spipu/html2pdf/blob/master/doc/barcode.md
Comprehensive list of supported 1D barcode types for the `type` attribute of the `` tag. Each entry includes the type name and a brief description, covering common standards like CODE 39, EAN, UPC, and various other industrial and postal codes.
```APIDOC
1D barcode types:
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
```
--------------------------------
### Html2Pdf::writeHTML Method Definition
Source: https://github.com/spipu/html2pdf/blob/master/doc/basic.md
Documents the `writeHTML` method of the `\Spipu\Html2Pdf\Html2Pdf` class, which converts an HTML string into PDF content. This method can be called multiple times to append content to the current page.
```APIDOC
\Spipu\Html2Pdf\Html2Pdf::writeHTML(
$html: string // The HTML content in string format to convert
)
```
--------------------------------
### Embed 1D Barcode in HTML
Source: https://github.com/spipu/html2pdf/blob/master/doc/barcode.md
Demonstrates how to embed a 1D barcode directly into HTML using the `` tag. It shows how to specify dimensions, type (EAN13), value, label presence, and inline CSS styling for width, height, color, and font size.
```html
```
--------------------------------
### Enable Default Debug Mode in Html2Pdf
Source: https://github.com/spipu/html2pdf/blob/master/doc/methods.md
Activate the default debug mode for Html2Pdf to assist with troubleshooting. This method enables internal debugging features.
```php
$html2pdf->setModeDebug();
```
--------------------------------
### Basic HTML2PDF Page Structure
Source: https://github.com/spipu/html2pdf/blob/master/doc/page.md
This snippet illustrates the fundamental HTML structure required for Html2Pdf to manage page layouts. It demonstrates the nesting of and within the tag, and explicitly states that standard and tags must be omitted.
```html
...
...
...
```
--------------------------------
### Add Allowed Host to Html2Pdf Security Service (PHP)
Source: https://github.com/spipu/html2pdf/blob/master/doc/security.md
Adds a specific host to the whitelist of allowed hosts for HTTP/HTTPS external files. By default, the whitelist is empty, so this method is used to permit external resources from a trusted domain.
```php
$html2pdf->getSecurityService()->addAllowedHost('www.html2pdf.fr');
```
--------------------------------
### TCPDF SetDisplayMode Method Parameters
Source: https://github.com/spipu/html2pdf/blob/master/doc/tcpdf_methods.md
Details the parameters for the `SetDisplayMode` method, including options for zoom, page layout, and document display mode, along with their possible string values and descriptions.
```APIDOC
SetDisplayMode(
$zoom: string|number,
$layout: string = 'SinglePage',
$mode: string = 'UseNone'
)
$zoom: The zoom to use. It can be one of the following string values or a number indicating the zooming factor to use.
- fullpage: displays the entire page on screen
- fullwidth: uses maximum width of window
- real: uses real size (equivalent to 100% zoom)
- default: uses viewer default mode
$layout: The page layout. Possible values are:
- SinglePage: Display one page at a time
- OneColumn: Display the pages in one column
- TwoColumnLeft: Display the pages in two columns, with odd-numbered pages on the left
- TwoColumnRight: Display the pages in two columns, with odd-numbered pages on the right
- TwoPageLeft (PDF 1.5): Display the pages two at a time, with odd-numbered pages on the left
- TwoPageRight (PDF 1.5): Display the pages two at a time, with odd-numbered pages on the right
$mode: A name object specifying how the document should be displayed when opened:
- UseNone: Neither document outline nor thumbnail images visible
- UseOutlines: Document outline visible
- UseThumbs: Thumbnail images visible
- FullScreen: Full-screen mode, with no menu bar, window controls, or any other window visible
- UseOC (PDF 1.5): Optional content group panel visible
- UseAttachments (PDF 1.6): Attachments panel visible
```
--------------------------------
### HTML2PDF Page Footer Tag
Source: https://github.com/spipu/html2pdf/blob/master/doc/page.md
This section describes the tag, which allows for complex HTML content to be used as the footer for the current page. Similar to the header, it must be placed immediately after the opening tag and requires the backtop attribute to be set on the parent tag for proper margin management. It supports css and class attributes.
```APIDOC
Page Footer Tag:
Purpose: Allows complex HTML as the footer of the current page.
Placement: Must be located just after the opening of the tag.
Content: Can contain any valid HTML.
Requirement: REQUIRED to specify the top margin, using the `backtop` attribute on the tag.
Attributes: `css`, `class`
```
--------------------------------
### HTML2PDF Page Header Tag
Source: https://github.com/spipu/html2pdf/blob/master/doc/page.md
This section describes the tag, which allows for complex HTML content to be used as the header for the current page. It must be placed immediately after the opening tag and requires the backtop attribute to be set on the parent tag for proper margin management. It supports css and class attributes.
```APIDOC
Page Header Tag:
Purpose: Allows complex HTML as the header of the current page.
Placement: Must be located just after the opening of the tag.
Content: Can contain any valid HTML.
Requirement: REQUIRED to specify the top margin, using the `backtop` attribute on the tag.
Attributes: `css`, `class`
```
--------------------------------
### TCPDF SetProtection Method Parameters
Source: https://github.com/spipu/html2pdf/blob/master/doc/tcpdf_methods.md
Defines the parameters for the `SetProtection` method, including various permissions to block, user/owner passwords, encryption modes (RC4, AES), and public key options for document security.
```APIDOC
SetProtection(
$permissions: array,
$userPass: string,
$ownerPass: string = null,
$mode: int = 0,
$pubkeys: array = null
)
$permissions: The set of permissions (specify the ones you want to block):
- print: Print the document
- modify: Modify the contents of the document by operations other than those controlled by 'fill-forms', 'extract' and 'assemble'
- copy: Copy or otherwise extract text and graphics from the document
- 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)
- fill-forms: Fill in existing interactive form fields (including signature fields), even if 'annot-forms' is not specified
- extract: Extract text and graphics (in support of accessibility to users with disabilities or for other purposes)
- assemble: Assemble the document (insert, rotate, or delete pages and create bookmarks or thumbnail images), even if 'modify' is not set
- 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.
- owner: (inverted logic - only for public-key) when set permits change of encryption and enables all other permissions.
$userPass: User password. Empty by default.
$ownerPass: Owner password. If not specified, a random value is used.
$mode: Encryption strength:
- 0 = RC4 40 bit
- 1 = RC4 128 bit
- 2 = AES 128 bit
- 3 = AES 256 bit
$pubkeys: 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')))
```
--------------------------------
### HTML Bookmark Tag Attributes API
Source: https://github.com/spipu/html2pdf/blob/master/doc/bookmark.md
Documents the attributes available for the HTML tag, used for defining hierarchical bookmarks in documents. It specifies the purpose and default values for each attribute, enabling control over the bookmark's text and its position in the hierarchy.
```APIDOC
Tag Attributes:
title: Title of the bookmark (No default)
level: Level of the bookmark, must be a positive integer. Level 0 is the main level (Default: 0)
```
--------------------------------
### Html2Pdf Custom HTML Tags
Source: https://github.com/spipu/html2pdf/blob/master/doc/README.md
Documentation for custom HTML tags introduced by Html2Pdf to control PDF generation layout and content, including page breaks, headers, footers, and special elements like barcodes and bookmarks.
```APIDOC
Description: Determines the orientation, margins (left, right, top, bottom), background image, background color, size, and position of a page, as well as its footer.
Attributes:
pageset="old": Keeps the header and footer from previous pages.
Description: Defines content for the page header.
Description: Defines content for the page footer.
Description: 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.
Description: Can insert barcodes in PDFs. Supports all barcode types available in TCPDF.
Description: Can insert QRcode 2D barcodes. (QR Code is a registered trademark of DENSO WAVE INCORPORATED)
Description: Can insert bookmarks in PDFs. It is also possible to automatically create an index at the end of the document.
Description: Specifies the end height for the last page.
Attributes:
end_height="30mm": Example attribute for height.
```