class Import extends AbstractWriter

Methods

addPdf(string $path)

Load a PDF with version 1.4 or 1.5 of the Adobe Spec for use with Mpdf.

addPage(int|array $id, array $args = [])

Display a page, or range of pages, from the loaded PDF in the PDF being rendered

addBlankPage(array $args = [])

Add a blank page to the PDF being rendered. Use in conjunction with $w->html().

array
getPdfPageSize()

Returns the current imported PDF page sizes (with $w->addPdf()). The class handles the page sizes internally, so you shouldn't need to use this method in your templates.

array
getPdfPageIds()

Returns the current loaded PDF page IDs. The class handles the IDs internally, so you shouldn't need to use this method in your templates.

Details

at line 92
addPdf(string $path)

Load a PDF with version 1.4 or 1.5 of the Adobe Spec for use with Mpdf.

Example

 // Import a PDF
 $w->addPdf( __DIR__ . '/pdfs/load-document.pdf' );

 // Load page #1 from PDF imported
 $w->addPage(1);

 // Import a 2nd PDF (you won't be able to load pages from PDF #1 after importing PDF #2)
 $w->addPdf( __DIR__ . '/pdfs/load-another-document.pdf' );

 // Load page #1 from 2nd PDF Imported
 $w->addPage(1);

Parameters

string $path The absolute path to the PDF being loaded

Exceptions

BadMethodCallException Thrown if the PDF file could not be found
Exception An exception will be thrown if you load a PDF that isn't version 1.4 or 1.5 of the Adobe Specification

at line 126
addPage(int|array $id, array $args = [])

Display a page, or range of pages, from the loaded PDF in the PDF being rendered

Example

 // Import a PDF
 $w->addPdf( __DIR__ . '/pdfs/load-document.pdf' );

 // Load page #1 from PDF
 $w->addPage( 1 );

 // Load a range of pages (pages 2 / 3 / 4 / 5) from the PDF
 $w->addPage( [ 2, 5 ] );

 // Load page #2 and set the top-margin to 20mm from the top of the page. This is useful when used with `$w->html()`
 $w->addPage( 2, [ 'margin-top' => 20 ] )

Parameters

int|array $id The current page to load, or a range of pages to load (max 2 array items)
array $args Additional page settings to pass to Mpdf. We recommend against trying to override sheet-size or orientation as the method calculates this automatically based off the PDF page size. See http://mpdf.github.io/reference/mpdf-functions/addpagebyarray.html for all available options

Exceptions

BadMethodCallException When $id is an array it should only contain two array items that signify the start and end of the PDF pages to load

at line 153
addBlankPage(array $args = [])

Add a blank page to the PDF being rendered. Use in conjunction with $w->html().

Example

 // Load a new page in the generated PDF with a sheet size of 200mm wide by 400mm heigh
 $w->addBlankPage( [ 'sheet-size' => [ 200, 400 ] ] );

Parameters

array $args Additional page settings to pass to Mpdf. See http://mpdf.github.io/reference/mpdf-functions/addpagebyarray.html for all available options

at line 171
array getPdfPageSize()

Returns the current imported PDF page sizes (with $w->addPdf()). The class handles the page sizes internally, so you shouldn't need to use this method in your templates.

Return Value

array The returned format will include the array key referencing the page number and the value referencing the page width and height: [ 1 => [ 200, 400 ], 2 => [ 150, 400 ] ]

at line 182
array getPdfPageIds()

Returns the current loaded PDF page IDs. The class handles the IDs internally, so you shouldn't need to use this method in your templates.

Return Value

array The returned format will include the array key referencing the page number and the value referencing the page ID: [ 1 => 'ID1', 2 => 'ID2' ]