All Projects → mpdf → Mpdf

mpdf / Mpdf

Licence: gpl-2.0
PHP library generating PDF files from UTF-8 encoded HTML

Programming Languages

PHP
23972 projects - #3 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to Mpdf

Receipts
Easy receipts and invoices for your Rails applications
Stars: ✭ 259 (-92.33%)
Mutual labels:  pdf
Starter Book
A book starter to kickstart your writing journey 🎉
Stars: ✭ 277 (-91.79%)
Mutual labels:  pdf
Rplos
R client for the PLoS Journals API
Stars: ✭ 289 (-91.44%)
Mutual labels:  pdf
Uxmpdfkit
An iOS PDF viewer and annotator written in Swift that can be embedded into any application.
Stars: ✭ 260 (-92.3%)
Mutual labels:  pdf
Thinreports Generator
Report Generator for Ruby
Stars: ✭ 268 (-92.06%)
Mutual labels:  pdf
Libmergepdf
PHP library for merging multiple PDFs
Stars: ✭ 282 (-91.64%)
Mutual labels:  pdf
Cloud Reports
Scans your AWS cloud resources and generates reports. Check out free hosted version:
Stars: ✭ 255 (-92.44%)
Mutual labels:  pdf
Redux Offline Docs
Redux documentation in PDF, ePub and MOBI formats for offline reading.
Stars: ✭ 292 (-91.35%)
Mutual labels:  pdf
Hummusrecipe
A powerful PDF tool for NodeJS based on HummusJS.
Stars: ✭ 274 (-91.88%)
Mutual labels:  pdf
Pdfocr
Adds text to PDF files using the cuneiform OCR software
Stars: ✭ 287 (-91.5%)
Mutual labels:  pdf
Tableexport
tableExport(table导出文件,支持json、csv、txt、xml、word、excel、image、pdf)
Stars: ✭ 261 (-92.27%)
Mutual labels:  pdf
Pdf
Rust library to read, manipulate and write PDF files.
Stars: ✭ 265 (-92.15%)
Mutual labels:  pdf
Reptile
爬取机械工业出版社所有的计算机方面的书
Stars: ✭ 282 (-91.64%)
Mutual labels:  pdf
Shaark
Self-hosted platform to keep and share your content: web links, posts, passwords and pictures.
Stars: ✭ 258 (-92.36%)
Mutual labels:  pdf
Camelot
Camelot: PDF Table Extraction for Humans
Stars: ✭ 3,150 (-6.67%)
Mutual labels:  pdf
Pdftilecut
pdftilecut lets you sub-divide a PDF page(s) into smaller pages so you can print them on small form printers.
Stars: ✭ 258 (-92.36%)
Mutual labels:  pdf
Quickbill
Create unlimited invoices for free.
Stars: ✭ 278 (-91.76%)
Mutual labels:  pdf
Pdf
数据科学方向 课件&资料
Stars: ✭ 293 (-91.32%)
Mutual labels:  pdf
Python Automation Scripts
Simple yet powerful automation stuffs.
Stars: ✭ 292 (-91.35%)
Mutual labels:  pdf
Pdf Flipbook
Browse PDF document like a book turning its pages
Stars: ✭ 279 (-91.73%)
Mutual labels:  pdf

mPDF is a PHP library which generates PDF files from UTF-8 encoded HTML.

It is based on FPDF and HTML2FPDF (see CREDITS), with a number of enhancements. mPDF was written by Ian Back and is released under the GNU GPL v2 licence.

Latest Stable Version Total Downloads License

If you are viewing this file on mPDF GitHub repository homepage or on Packagist, please note that the default repository branch is development which can differ from the last stable release.

Requirements

PHP versions and extensions

  • mPDF >=7.0 is supported on PHP ^5.6 || ~7.0.0 || ~7.1.0 || ~7.2.0
  • PHP 7.3 is supported since mPDF v7.1.7
  • PHP 7.4 is supported since mPDF v8.0.4
  • PHP 8.0 is supported since mPDF v8.0.10
  • PHP 8.1 is supported as of mPDF v8.0.13

PHP mbstring and gd extensions have to be loaded.

Additional extensions may be required for some advanced features such as zlib for compression of output and embedded resources such as fonts, bcmath for generating barcodes or xml for character set conversion and SVG handling.

Known server caveats

mPDF has some problems with fetching external HTTP resources with single threaded servers such as php -S. A proper server such as nginx (php-fpm) or Apache is recommended.

Support us

Consider supporting development of mPDF with a donation of any value. Donation button can be found on the main page of the documentation.

Installation

Official installation method is via composer and its packagist package mpdf/mpdf.

$ composer require mpdf/mpdf

Usage

The simplest usage (since version 7.0) of the library would be as follows:

<?php

require_once __DIR__ . '/vendor/autoload.php';

$mpdf = new \Mpdf\Mpdf();
$mpdf->WriteHTML('<h1>Hello world!</h1>');
$mpdf->Output();

This will output the PDF inline to the browser as application/pdf Content-type.

Setup & Configuration

All configuration directives can be set by the $config parameter of the constructor.

It is recommended to set one's own temporary directory via tempDir configuration variable. The directory must have write permissions (mode 775 is recommended) for users using mPDF (typically cli, webserver, fpm).

Warning: mPDF will clean up old temporary files in the temporary directory. Choose a path dedicated to mPDF only.

<?php

$mpdf = new \Mpdf\Mpdf(['tempDir' => __DIR__ . '/tmp']);

By default, the temporary directory will be inside vendor directory and will have write permissions from post_install composer script.

For more information about custom temporary directory see the note on Folder for temporary files in the section on Installation & Setup in the manual.

If you have problems, please read the section on troubleshooting in the manual.

About CSS support and development state

mPDF as a whole is a quite dated software. Nowadays, better alternatives are available, albeit not written in PHP.

Use mPDF if you cannot use non-PHP approach to generate PDF files or if you want to leverage some of the benefits of mPDF over browser approach – color handling, pre-print, barcodes support, headers and footers, page numbering, TOCs, etc. But beware that a HTML/CSS template tailored for mPDF might be necessary.

If you are looking for state of the art CSS support, mirroring existing HTML pages to PDF, use headless Chrome.

mPDF will still be updated to enhance some internal capabilities and to support newer versions of PHP, but better and/or newer CSS support will most likely not be implemented.

Online manual

Online manual is available at https://mpdf.github.io/.

General troubleshooting

For general questions or troubleshooting please use Discussions.

You can also use the mpdf tag at Stack Overflow as the StackOverflow user base is more likely to answer you in a timely manner.

Contributing

Before submitting issues and pull requests please read the CONTRIBUTING.md file.

Unit Testing

Unit testing for mPDF is done using PHPUnit.

To get started, run composer install from the command line while in the mPDF root directory (you'll need composer installed first).

To execute tests, run composer test from the command line while in the mPDF root directory.

Any assistance writing unit tests for mPDF is greatly appreciated. If you'd like to help, please note that any PHP file located in the /tests/ directory will be autoloaded when unit testing.

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].