Category: PDF

My fun time with PDF delivery.

Save and Display DOMPDF

Save PDF file on server and display in users browser: $file_to_save = '/home/stsnew/public_html/pdf/file.pdf'; //save the pdf file on the server file_put_contents($file_to_save, $dompdf->output()); //print the pdf file to the screen for saving header('Content-type: application/pdf'); header('Content-Disposition: inline; filename="file.pdf"'); header('Content-Transfer-Encoding:

Install wkhtmltopdf & wkhtmltoimage AlmaLinux

Wkhtmltopdf is a powerful open-source command line tool for converting HTML documents into PDF files. It is based on the webkit engine, which is used by many popular browsers such as Safari and Chrome. Wkhtmltopdf can be used to generate high-quality PDFs from HTML documents, and it supports a wide range of features including page headers and footers, page margins, table of contents, and more.

PDF.js Open Links in New Tab

Since the release of PDF.js 2.0.943 you can force URL to open in a new tab: <script> function applyConfig() { PDFViewerApplication.preferences.set('externalLinkTarget', 2); } document.addEventListener('DOMContentLoaded', applyConfig, true); </script> Older versions we used: PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK; This is also a hack that might work on newer versions but