1
- # vianetz PDF Library
1
+ # vianetz Pdf Library
2
2
3
3
This library offers an easy-to-use API for PDF generation and merging.
4
- Internally it uses the DomPDF library for PDF generation and TCPDF for merging.
4
+ Internally it uses the [ DomPDF library] ( https://github.com/dompdf/dompdf ) for PDF generation and [ FPDI] ( https://github.com/Setasign/FPDI ) for merging.
5
+
6
+ More information about this PDF API can also be found [ on my website] ( https://www.vianetz.com/en/pdf-invoice-api-magento/ ) .
5
7
6
8
## Usage
7
9
8
- ### Create PDF document from HTML contents
10
+ ### Create PDF document from HTML contents
11
+
9
12
``` php
10
13
// Create a new pdf instance.
11
- $pdf = Vianetz\Pdf\Model\PdfFactory::general()->create();
14
+ $pdf = \ Vianetz\Pdf\Model\PdfFactory::general()->create();
12
15
13
16
// Create the document. You can return any kind of HTML content here.
14
- $document = new \Vianetz\Pdf\Model\Document();
15
- $document->setHtmlContents('<strong >Hello</strong > World!');
17
+ $document = new \Vianetz\Pdf\Model\HtmlDocument('<strong >Hello</strong > World!');
16
18
17
19
// Add our document to the pdf. You can add as many documents as you like
18
20
// as they will all be merged into one PDF file.
19
- $pdf->addDocument ($document);
21
+ $pdf->add ($document);
20
22
21
23
// Save the resulting PDF to file test.pdf - That's it :-)
22
24
$pdf->saveToFile('test.pdf');
@@ -28,15 +30,14 @@ $pdf->saveToFile('test.pdf');
28
30
$pdfString = file_get_contents('test1.pdf');
29
31
30
32
// Setup things
31
- $pdf = Vianetz\Pdf\Model\PdfFactory::general()->create();
32
- $pdfMerge = Vianetz\Pdf\Model\PdfMerge::create();
33
+ $pdfMerge = \Vianetz\Pdf\Model\PdfMerge::create();
33
34
34
35
// Do the merge.
35
- $pdfMerge->mergePdfString($pdfString);
36
+ $pdfMerge->mergePdfString($pdfString, 'background.pdf' );
36
37
$pdfMerge->mergePdfFile('test2.pdf');
37
38
38
39
// Save the result PDF to file result.pdf.
39
- $ pdfMerge->saveToFile('result.pdf' );
40
+ file_put_contents($fileName, $ pdfMerge->toPdf() );
40
41
```
41
42
42
43
### Tips & Tricks
@@ -50,12 +51,6 @@ Please find the Frequently Asked Questions [on my website](https://www.vianetz.c
50
51
If you have any issues or suggestions with this extension, please do not hesitate to
51
52
[ contact me] ( https://www.vianetz.com/en/contacts ) .
52
53
53
- ## Credits
54
- Of course this extension would not have been possible without the great open source eco-system.
55
- Therewith credits go to:
56
- - [ DomPDF] ( https://github.com/dompdf/dompdf )
57
- - [ FPDI] ( https://github.com/Setasign/FPDI )
58
-
59
54
## License
60
55
[ GNU General Public License v3.0] ( https://www.gnu.org/licenses/gpl-3.0.html )
61
56
See also LICENSE file.
0 commit comments