All Projects → dompdf → Dompdf

dompdf / Dompdf

Licence: lgpl-2.1
HTML to PDF converter for PHP

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to Dompdf

pydf
PDF generation in python using wkhtmltopdf for heroku and docker
Stars: ✭ 68 (-99.19%)
Mutual labels:  html-to-pdf, pdf-generation
api2pdf.php
PHP client library for the Api2Pdf.com REST API - Convert HTML to PDF, URL to PDF, Office Docs to PDF, Merge PDFs, HTML to Image, URL to Image, HTML to Docx, HTML to Xlsx, PDF to HTML, Thumbnail preview of office files
Stars: ✭ 42 (-99.5%)
Mutual labels:  html-to-pdf, pdf-generation
docraptor-ruby
A native Ruby client for the DocRaptor HTML to PDF generation API
Stars: ✭ 20 (-99.76%)
Mutual labels:  html-to-pdf, pdf-generation
Docotic.Pdf.Samples
C# and VB.NET samples for Docotic.Pdf library
Stars: ✭ 52 (-99.38%)
Mutual labels:  html-to-pdf, pdf-generation
Snappy
PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page. Wrapper for wkhtmltopdf/wkhtmltoimage
Stars: ✭ 3,986 (-52.81%)
Mutual labels:  html-to-pdf, pdf-generation
Terrarum Sans Bitmap
The real multilingual bitmap font for video games
Stars: ✭ 34 (-99.6%)
Mutual labels:  font
Gmail Fixed Font
Use your browser's monospace font for message body text in Gmail
Stars: ✭ 44 (-99.48%)
Mutual labels:  font
Web Font Loading Recipes
A bunch of demos for different web font loading strategies. Companion to https://www.zachleat.com/web/comprehensive-webfonts/ Read more: https://www.zachleat.com/web/recipes/
Stars: ✭ 964 (-88.59%)
Mutual labels:  font
Unicons
1000+ Pixel-perfect vector icons and Iconfont for your next project.
Stars: ✭ 911 (-89.21%)
Mutual labels:  font
Open Relay
Free and open source fonts from Kreative Software
Stars: ✭ 48 (-99.43%)
Mutual labels:  font
Font Awesome Php
A PHP library for Font Awesome 4.7.
Stars: ✭ 47 (-99.44%)
Mutual labels:  font
Twemoji Color Font
Twitter Unicode 13 emoji color OpenType-SVG font for Linux/MacOS/Windows
Stars: ✭ 1,006 (-88.09%)
Mutual labels:  font
Webfont Test
Test and analyze fonts for the web: Google fonts, system fonts and custom fonts.
Stars: ✭ 36 (-99.57%)
Mutual labels:  font
Pdfsave
Convert websites into readable PDFs
Stars: ✭ 46 (-99.46%)
Mutual labels:  pdf-generation
Google Type
Collaborative typography project using select passages from Aesop's Fables set to Google Fonts
Stars: ✭ 971 (-88.5%)
Mutual labels:  font
Knpsnappybundle
Easily create PDF and images in Symfony by converting html using webkit
Stars: ✭ 1,038 (-87.71%)
Mutual labels:  pdf-generation
Alivepdf
[Official AlivePDF] - AlivePDF is a client side AS3 PDF generation library for Adobe Flash, Flex and AIR
Stars: ✭ 29 (-99.66%)
Mutual labels:  pdf-generation
Linearx Font
Procedurally generated fonts
Stars: ✭ 41 (-99.51%)
Mutual labels:  font
Yii2 Widget Rating
A Yii2 widget for the simple yet powerful bootstrap-star-rating plugin with fractional rating support (sub repo split from yii2-widgets)
Stars: ✭ 47 (-99.44%)
Mutual labels:  font
Mkdocs With Pdf
Generate a single PDF file from MkDocs repository.
Stars: ✭ 39 (-99.54%)
Mutual labels:  pdf-generation

Dompdf

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

Dompdf is an HTML to PDF converter

At its heart, dompdf is (mostly) a CSS 2.1 compliant HTML layout and rendering engine written in PHP. It is a style-driven renderer: it will download and read external stylesheets, inline style tags, and the style attributes of individual HTML elements. It also supports most presentational HTML attributes.

This document applies to the latest stable code which may not reflect the current release. For released code please navigate to the appropriate tag.


Check out the demo and ask any question on StackOverflow or in Discussions.

Follow us on Twitter.


Features

  • Handles most CSS 2.1 and a few CSS3 properties, including @import, @media & @page rules
  • Supports most presentational HTML 4.0 attributes
  • Supports external stylesheets, either local or through http/ftp (via fopen-wrappers)
  • Supports complex tables, including row & column spans, separate & collapsed border models, individual cell styling
  • Image support (gif, png (8, 24 and 32 bit with alpha channel), bmp & jpeg)
  • No dependencies on external PDF libraries, thanks to the R&OS PDF class
  • Inline PHP support
  • Basic SVG support (see "Limitations" below)

Requirements

  • PHP version 7.1 or higher
  • DOM extension
  • MBString extension
  • php-font-lib
  • php-svg-lib

Note that some required dependencies may have further dependencies (notably php-svg-lib requires sabberworm/php-css-parser).

Recommendations

  • OPcache (OPcache, XCache, APC, etc.): improves performance
  • GD (for image processing)
  • IMagick or GMagick extension: improves image processing performance

Visit the wiki for more information: https://github.com/dompdf/dompdf/wiki/Requirements

About Fonts & Character Encoding

PDF documents internally support the following fonts: Helvetica, Times-Roman, Courier, Zapf-Dingbats, & Symbol. These fonts only support Windows ANSI encoding. In order for a PDF to display characters that are not available in Windows ANSI, you must supply an external font. Dompdf will embed any referenced font in the PDF so long as it has been pre-loaded or is accessible to dompdf and reference in CSS @font-face rules. See the font overview for more information on how to use fonts.

The DejaVu TrueType fonts have been pre-installed to give dompdf decent Unicode character coverage by default. To use the DejaVu fonts reference the font in your stylesheet, e.g. body { font-family: DejaVu Sans; } (for DejaVu Sans). The following DejaVu 2.34 fonts are available: DejaVu Sans, DejaVu Serif, and DejaVu Sans Mono.

Easy Installation

Install with composer

To install with Composer, simply require the latest version of this package.

composer require dompdf/dompdf

Make sure that the autoload file from Composer is loaded.

// somewhere early in your project's loading, require the Composer autoloader
// see: http://getcomposer.org/doc/00-intro.md
require 'vendor/autoload.php';

Download and install

Download a packaged archive of dompdf and extract it into the directory where dompdf will reside

Use the packaged release autoloader to load dompdf, libraries, and helper functions in your PHP:

// include autoloader
require_once 'dompdf/autoload.inc.php';

Note: packaged releases are named according using semantic versioning (dompdf_MAJOR-MINOR-PATCH.zip). So the 1.0.0 release would be dompdf_1-0-0.zip. This is the only download that includes the autoloader for Dompdf and all its dependencies.

Install with git

From the command line, switch to the directory where dompdf will reside and run the following commands:

git clone https://github.com/dompdf/dompdf.git
cd dompdf/lib

git clone https://github.com/PhenX/php-font-lib.git php-font-lib
cd php-font-lib
git checkout 0.5.1
cd ..

git clone https://github.com/PhenX/php-svg-lib.git php-svg-lib
cd php-svg-lib
git checkout v0.3.2
cd ..

git clone https://github.com/sabberworm/PHP-CSS-Parser.git php-css-parser
cd php-css-parser
git checkout 8.1.0

Require dompdf and it's dependencies in your PHP. For details see the autoloader in the utils project.

Quick Start

Just pass your HTML in to dompdf and stream the output:

// reference the Dompdf namespace
use Dompdf\Dompdf;

// instantiate and use the dompdf class
$dompdf = new Dompdf();
$dompdf->loadHtml('hello world');

// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'landscape');

// Render the HTML as PDF
$dompdf->render();

// Output the generated PDF to Browser
$dompdf->stream();

Setting Options

Set options during dompdf instantiation:

use Dompdf\Dompdf;
use Dompdf\Options;

$options = new Options();
$options->set('defaultFont', 'Courier');
$dompdf = new Dompdf($options);

or at run time

use Dompdf\Dompdf;

$dompdf = new Dompdf();
$options = $dompdf->getOptions();
$options->setDefaultFont('Courier');
$dompdf->setOptions($options);

See Dompdf\Options for a list of available options.

Resource Reference Requirements

In order to protect potentially sensitive information Dompdf imposes restrictions on files referenced from the local file system or the web.

Files accessed through web-based protocols have the following requirements:

  • The Dompdf option "isRemoteEnabled" must be set to "true"
  • PHP must either have the curl extension enabled or the allow_url_fopen setting set to true

Files accessed through the local file system have the following requirement:

  • The file must fall within the path(s) specified for the Dompdf "chroot" option

Limitations (Known Issues)

  • Dompdf is not particularly tolerant to poorly-formed HTML input. To avoid any unexpected rendering issues you should either enable the built-in HTML5 parser at runtime ($options->setIsHtml5ParserEnabled(true);) or run your HTML through a HTML validator/cleaner (such as Tidy or the W3C Markup Validation Service).
  • Table cells are not pageable, meaning a table row must fit on a single page.
  • Elements are rendered on the active page when they are parsed.
  • Embedding "raw" SVG's (<svg><path...></svg>) isn't working yet, you need to either link to an external SVG file, or use a DataURI like this:
    $html = '<img src="data:image/svg+xml;base64,' . base64_encode($svg) . '" ...>';
    Watch https://github.com/dompdf/dompdf/issues/320 for progress

Donate button

If you find this project useful, please consider making a donation. Any funds donated will be used to help further development on this project.)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].