Serverside PDF
wkHTMLtoPDF
Installation auf 1und1/Ionos server with ssh
-
Connect via SSH to the server (https://www.ionos.de/hilfe/index.php?id=2923)
-
Download the correct version (in my case):
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.buster_amd64.deb
- Execute the following statements:
ar vx wkhtmltox_0.12.6-1.buster_amd64.deb
which should result in the following folders/files:
debian-binary
control.tar.gz
data.tar.xz
- Execute:
tar xf data.tar.xz
- Check if everything work:
./usr/local/bin/wkhtmltopdf 'https://google.de' google.pdf
Bugs
- Images without DPI info aren't getting optimized https://github.com/wkhtmltopdf/wkhtmltopdf/issues/4646#issuecomment-613903652
- Images should be full paths
- ignores Exif Orientation Information (portrait images can appear in landscape) https://github.com/wkhtmltopdf/wkhtmltopdf/issues/4902
typeset.sh
typeset.sh is based on PHP
Price: 500 EUR for Self-hosted Version
mPDF
Dompdf
-
http://pxd.me/dompdf/www/examples.php#css_at_font_face.html,html
-
Unicode Problems?
-
Can't encrypt when include custom fonts.
Encrypted PDF
https://gist.github.com/marcus-at-localhost/04bebc64832cd618a872e146a0e48b26#file-info-md
FPDI
FPDI is used to merge PDFs. It needs the FPDF library to work.
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