alberon/htmltopdf

This package is abandoned and no longer maintained. No replacement package was suggested.

HTML to PDF PHP wrapper with executable files

1.0.1 2015-09-08 16:08 UTC

This package is not auto-updated.

Last update: 2021-02-12 08:59:57 UTC


README

PHP wrapper for wkhtmltopdf http://wkhtmltopdf.org/downloads.html

Install

  1. Install Composer:

    curl -s https://getcomposer.org/installer | php
  2. Add to your composer.json file:

    composer require alberon/htmltopdf
  3. Usage Instructions:

    // Require the PDF class at the top of the file
    require ABSPATH . '/../vendor/autoload.php';
    use Alberon\htmltopdf\PDF;
    
    // Open up an ob buffer to capture all the following html
    ob_start();
    // HTML CODE
    // Close the ob buffer and get the html into a variable
    $html = ob_get_clean();
    
    // Setup the PDF class with the generated html
    $pdf = new PDF($html);
    
    // Set wkhtmltopdf version
    $pdf->setVersion('amd64');
    
    // Set whether to include detailed errors or a generic error
    // $pdf->showErrors();
    $pdf->hideErrors();
    
    // Output the PDF
    $pdf->outputAsPDF('my_filename');