Serverside PDF

Libs

wkHTMLtoPDF

Installation auf 1und1 Server mit ssh

wkHTMLtoPDF 0.12.4 ist die letzte generische stand alone Version https://github.com/wkhtmltopdf/wkhtmltopdf/releases

$ wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
$ tar -xJf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz

Bugs

Dompdf

Create PDF

https://gist.github.com/marcus-at-localhorst/04bebc64832cd618a872e146a0e48b26

FPDI

FPDI is used to merge PDFs. It needs the FPDF library to work.

  1. Download latest version of FPDI
  2. Download FPDI_Protection
  3. Download FPDF

Simple example

    require_once('fpdf181/fpdf.php');
    require_once('FPDI-1.6.1/fpdi.php');
    require_once('FPDI-1.6.1/FPDI_Protection.php');
    $pdf = new FPDI_Protection();
    $pagecount = $pdf->setSourceFile($origFile);

    // copy all pages from the old unprotected pdf in the new one
    for ($loop = 1; $loop <= $pagecount; $loop++) {
        $tplidx = $pdf->importPage($loop);
        $pdf->addPage();
        $pdf->useTemplate($tplidx);
    }

    $pdf->SetProtection(array('print'),null, $password);
    $pdf->Output($destFile,'F'); // F write, D download