Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time

TCPDF Methods

back

All the TCPDF methods can be used, by using the pdf property:

$html2pdf->pdf->...

Display Mode

You can change how your PDF document will be displayed, with the SetDisplayMode method:

$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.
  • 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 SinglePage 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 UseNone 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

Document Information

You can change the document information, with the following methods:

$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:

$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):
  • 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 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