PHP code example of 10usb / pdf-lib

1. Go to this page and download the library: Download 10usb/pdf-lib 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/ */

    

10usb / pdf-lib example snippets


$file = new File('test.pdf');
$file->getInformation()
	->setTitle('My PDF Library')
	->setSubject('How to create a pdf library')
	->setAuthor('10usb');

$catalog = $file->getCatalog()->setSize(595.276, 841.890);


$page = $catalog->addPage();

$canvas = $page->getCanvas();

$canvas->setStrokeColor(255, 0, 255);
$canvas->setLineWidth(5);
$canvas->line(30, 30, 50, 100);


$canvas->setFillColor(50, 50, 50);
$canvas->setFont($page->getFont('Helvetica', 11));
$canvas->text(50, 50, "PDF Library");
$canvas->text(50, 70, "You start with...");

$file->flush();