Zeta Components - high quality PHP components

Zeta Components Manual :: Docs For Class ezcDocumentPdf

Document::ezcDocumentPdf

Class ezcDocumentPdf

Document handler for PDF documents.

This document handler can load Docbook documents and generate PDF documents from them. It can be configured using its option class ezcDocumentPdfOptions. The example below shows the configuration of a driver.

  1.   // Load the docbook document and create a PDF from it
  2.   $pdf = new ezcDocumentPdf();
  3.   $pdf->options->driver = new ezcDocumentPdfHaruDriver();
  4.  
  5.   // Load a custom style sheet
  6.   $pdf->loadStyles( 'custom.css' );
  7.  
  8.   // Add a customized footer
  9.       new ezcDocumentPdfFooterOptions( array(
  10.           'showDocumentTitle'  => false,
  11.           'showDocumentAuthor' => false,
  12.           'height'             => '10mm',
  13.       ) )
  14.   ) );
  15.  
  16.   // Add a customized header
  17.       new ezcDocumentPdfFooterOptions( array(
  18.           'showPageNumber'     => false,
  19.           'height'             => '10mm',
  20.       ) )
  21.   ) );
  22.  
  23.   $pdf->createFromDocbook( $docbook );
  24.   file_put_contents( __FILE__ . '.pdf', $pdf );

Like shown in the example, it is possible to load any amount of custom style definitions and register additional PDF parts, like headers and footers.

Source for this file: /Document/src/document/pdf.php

ezcDocument
   |
   --ezcDocumentPdf
Version:   //autogen//

Member Variables

protected string $content
The generated PDF
protected array(ezcDocumentPdfPart) $pdfParts = array()
List of PDF parts to append to documents
protected ezcDocumentPcssStyleInferencer $styles
Container for style directives.

Inherited Member Variables

From ezcDocument
protected ezcDocument::$errors
protected ezcDocument::$options
protected ezcDocument::$path

Method Summary

public void createFromDocbook( $document )
Create document from docbook document
public ezcDocumentDocbook getAsDocbook( )
Return document compiled to the docbook format
public void loadString( $string )
Create document from input string
public void loadStyles( $file )
Load style definition file
public void registerPdfPart( $part )
Append a PDF part
public string save( )
Return document as string

Inherited Methods

From ezcDocument
public ezcDocument ezcDocument::__construct()
Construct new document
public abstract void ezcDocument::createFromDocbook()
Create document from docbook document
public abstract ezcDocumentDocbook ezcDocument::getAsDocbook()
Return document compiled to the docbook format
public array ezcDocument::getErrors()
Return list of errors occured during visiting the document.
public string ezcDocument::getPath()
Get document base path
public void ezcDocument::loadFile()
Create document from file
public abstract void ezcDocument::loadString()
Create document from input string
public abstract string ezcDocument::save()
Return document as string
public void ezcDocument::setPath()
Set document base path
public void ezcDocument::triggerError()
Trigger visitor error

Methods

createFromDocbook

void createFromDocbook( ezcDocumentDocbook $document )

Create document from docbook document

A document of the docbook format is provided and the internal document structure should be created out of this.

This method is required for all formats to have one central format, so that each format can be compiled into each other format using docbook as an intermediate format.

You may of course just call an existing converter for this conversion.

Parameters:
Name Type Description
$document ezcDocumentDocbook
Redefinition of:
Method Description
ezcDocument::createFromDocbook() Create document from docbook document

getAsDocbook

ezcDocumentDocbook getAsDocbook( )

Return document compiled to the docbook format

The internal document structure is compiled to the docbook format and the resulting docbook document is returned.

This method is required for all formats to have one central format, so that each format can be compiled into each other format using docbook as an intermediate format.

You may of course just call an existing converter for this conversion.

Redefinition of:
Method Description
ezcDocument::getAsDocbook() Return document compiled to the docbook format

loadString

void loadString( string $string )

Create document from input string

Create a document of the current type handler class and parse it into a usable internal structure.

Parameters:
Name Type Description
$string string
Redefinition of:
Method Description
ezcDocument::loadString() Create document from input string

loadStyles

void loadStyles( string $file )

Load style definition file

Parse and load a PCSS file and use the resulting style definitions for rendering.

Parameters:
Name Type Description
$file string

registerPdfPart

void registerPdfPart( ezcDocumentPdfPart $part )

Append a PDF part

Register additional PDF parts to be included in the rendering process, like headers and footers.

Parameters:
Name Type Description
$part ezcDocumentPdfPart

save

string save( )

Return document as string

Serialize the document to a string an return it.

Redefinition of:
Method Description
ezcDocument::save() Return document as string
Documentation generated by phpDocumentor 1.4.3