net-tools / pdf
Composer library for handling PDF files through TCPDF lib
1.0.7
2023-09-10 12:46 UTC
Requires
- php: >= 7.0.0
- tecnickcom/tcpdf: ^6.2.17
README
Composer library for creating PDF files through TCPDF lib
Setup instructions
To install net-tools/pdf package, just require it through composer : require net-tools/pdf:^1.0.0
How to use ?
The package has an only helper class, PdfHelper
; you have to create an object of that class before using it.
The class constructor requires the following parameters :
By default, PDF files created don't have any header/footer, but the header may be specified with setHeader
method.
To create the document, just use HTML tags and simple CSS formatting (with addHTMLPage
), and get the PDF file by calling output
method.
Sample
$pdfh = new \Nettools\Pdf\PdfHelper($cfgfile, 'P', 'Me', 'Dummy title'); $pdfh->addHTMLPage("<p><strong>This is a simple PDF file</strong></p><p>with two lines. First is bold, the second is in normal print.</p>"); $pdfh->output($path_to_file_to_be_created);
You can also create a blank page, and then output several strings to it :
$pdfh->addPage(); $pdfh->writeHTML("<p>first line</p>"); $pdfh->writeHTML("<p>second line</p>"); $pdfh->output($path_to_file_to_be_created);