Skip to content
Go to file
Latest commit 94730a4 Nov 4, 2018 History
Little bug
2 contributors

Users who have contributed to this file

@spipu @dynshon
48 lines (34 sloc) 1.48 KB




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
  • getInvalidTag
  • getHtmlLine
Occurs if the html is no valid
ImageException 2
  • getImage
Occurs if the asked image does not exist
LongSentenceException 3
  • getSentence
  • getWidthBox
  • getLength
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:

try {
    use Spipu\Html2Pdf\Html2Pdf;
    use Spipu\Html2Pdf\Exception\Html2PdfException;
    use Spipu\Html2Pdf\Exception\ExceptionFormatter;

    $html2pdf = new Html2Pdf('P', 'A4', 'fr');
} catch (Html2PdfException $e) {

    $formatter = new ExceptionFormatter($e);
    echo $formatter->getHtmlMessage();


You can’t perform that action at this time.