PHP code example of raudius / phpdf

1. Go to this page and download the library: Download raudius/phpdf 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/ */

    

raudius / phpdf example snippets


$pdf = Phpdf::create();

$pdf = Phpdf::fopen('example.pdf', true);           // Overwrite = true
$pdf = Phpdf::fopen(fopen('example.pdf', 'rb'));    // Overwrite = false
 
$pdf = Phpdf::create(file_get_contents('example.pdf'));

// Combine 3 PDF files into 1
$pdf_merged = (new Merge([
  Phpdf::fopen('file1.pdf'),
  Phpdf::fopen('file2.pdf'),
  Phpdf::fopen('file3.pdf')
]))->execute();

// Keep just the 1st, 3rd and 4th pages.
(new Trim($pdf_merged, '1,3,4'))->execute($pdf_merged);

$pdf = Phpdf::create();
$pdf->saveAs('copy1.pdf');
$pdf->saveAs('copy2.pdf');
$pdf->saveAs('copy3.pdf');