Last change
on this file since 428 was 347, checked in by roby, 3 years ago |
Aggiornamento per compatibilità con php7.4
|
File size:
1.5 KB
|
Line | |
---|
1 | # Exception
|
---|
2 |
|
---|
3 | [back](./README.md)
|
---|
4 |
|
---|
5 | ## Exceptions
|
---|
6 |
|
---|
7 | All the specific Html2Pdf exceptions are under the namespace `\Spipu\Html2Pdf\Exception`;
|
---|
8 |
|
---|
9 | Exception|Error Code|Additional Info|Description
|
---|
10 | ---------|----------|---------------|-----------
|
---|
11 | Html2PdfException | 0 | | Occurs for every generic error during the process
|
---|
12 | HtmlParsingException |Â 1 | <ul><li>getInvalidTag</li><li>getHtmlLine</li></ul> | Occurs if the html is no valid
|
---|
13 | ImageException | 2 | <ul><li>getImage</li></ul> | Occurs if the asked image does not exist
|
---|
14 | LongSentenceException | 3 | <ul><li>getSentence</li><li>getWidthBox</li><li>getLength</li></ul> | Occurs is a sentence is too long and does not fit in the current box
|
---|
15 | TableException | 4 | | Occurs if the content of a TD does not fit on only one page
|
---|
16 |
|
---|
17 | ## Exception Format
|
---|
18 |
|
---|
19 | An exception formatter can be used to display the exceptions: `\Spipu\Html2Pdf\Exception\ExceptionFormatter`.
|
---|
20 |
|
---|
21 | It takes the current exception as a parameter of the constructor.
|
---|
22 |
|
---|
23 | It provides 2 methods
|
---|
24 |
|
---|
25 | * getMessage()
|
---|
26 | * getHtmlMessage();
|
---|
27 |
|
---|
28 | Usage example:
|
---|
29 |
|
---|
30 | ```php
|
---|
31 | try {
|
---|
32 | use Spipu\Html2Pdf\Html2Pdf;
|
---|
33 | use Spipu\Html2Pdf\Exception\Html2PdfException;
|
---|
34 | use Spipu\Html2Pdf\Exception\ExceptionFormatter;
|
---|
35 |
|
---|
36 | $html2pdf = new Html2Pdf('P', 'A4', 'fr');
|
---|
37 | $html2pdf->setDefaultFont('Arial');
|
---|
38 | $html2pdf->writeHTML($htmlContent);
|
---|
39 | $html2pdf->output();
|
---|
40 | } catch (Html2PdfException $e) {
|
---|
41 | $html2pdf->clean();
|
---|
42 |
|
---|
43 | $formatter = new ExceptionFormatter($e);
|
---|
44 | echo $formatter->getHtmlMessage();
|
---|
45 | }
|
---|
46 | ```
|
---|
47 |
|
---|
48 | [back](./README.md)
|
---|
Note:
See
TracBrowser
for help on using the repository browser.