PHP code example of vianetz / pdf-generator
1. Go to this page and download the library: Download vianetz/pdf-generator library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
vianetz / pdf-generator example snippets
// Create a new pdf instance.
$pdf = Vianetz\Pdf\Model\PdfFactory::general()->create();
// Create the document. You can return any kind of HTML content here.
$document = new \Vianetz\Pdf\Model\Document();
$document->setHtmlContents('<strong>Hello</strong> World!');
// Add our document to the pdf. You can add as many documents as you like
// as they will all be merged into one PDF file.
$pdf->addDocument($document);
// Save the resulting PDF to file test.pdf - That's it :-)
$pdf->saveToFile('test.pdf');
// Load some random PDF contents
$pdfString = file_get_contents('test1.pdf');
// Setup things
$pdf = Vianetz\Pdf\Model\PdfFactory::general()->create();
$pdfMerge = Vianetz\Pdf\Model\PdfMerge::create();
// Do the merge.
$pdfMerge->mergePdfString($pdfString);
$pdfMerge->mergePdfFile('test2.pdf');
// Save the result PDF to file result.pdf.
$pdfMerge->saveToFile('result.pdf');