Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/dompdf/dompdf
Browse files Browse the repository at this point in the history
  • Loading branch information
Mulkave committed Aug 3, 2021
2 parents 13cdbd6 + 4c65810 commit db54049
Show file tree
Hide file tree
Showing 76 changed files with 5,753 additions and 3,407 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* text=auto eol=lf
*.json text
*.xml text
*.php text
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ composer.phar
composer.lock
phpunit.xml
vendor
build
.idea
.project
lib/fonts/*.afm.php
Expand Down
20 changes: 14 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
language: php

php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4
- 8.0
- nightly
- hhvm

install: travis_retry composer install --no-interaction --prefer-source

before_script:
- composer require php-coveralls/php-coveralls --no-interaction

script:
- vendor/bin/phpunit
# - vendor/bin/phpcs --standard=phpcs.xml src
- vendor/bin/phpunit --coverage-clover build/logs/clover.xml
- vendor/bin/phpcs --standard=phpcs.xml src

matrix:
allow_failures:
- php: nightly
- php: hhvm

fast_finish: true

after_success:
- travis_retry php vendor/bin/php-coveralls
91 changes: 59 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ release. For released code please

----

**Check out the [demo](https://dompdf.net/examples.php) and ask any
question on [StackOverflow](http://stackoverflow.com/questions/tagged/dompdf) or
on the [Google Groups](http://groups.google.com/group/dompdf).**
**Check out the [demo](http://eclecticgeek.com/dompdf/debug.php) and ask any
question on [StackOverflow](https://stackoverflow.com/questions/tagged/dompdf) or
in [Discussions](https://github.com/dompdf/dompdf/discussions).**

Follow us on [![Twitter](http://twitter-badges.s3.amazonaws.com/twitter-a.png)](http://www.twitter.com/dompdf) or
[![Follow us on Google+](https://ssl.gstatic.com/images/icons/gplus-16.png)](https://plus.google.com/108710008521858993320?prsrc=3).
Follow us on [![Twitter](http://twitter-badges.s3.amazonaws.com/twitter-a.png)](http://www.twitter.com/dompdf).

---

Expand All @@ -44,20 +43,23 @@ Follow us on [![Twitter](http://twitter-badges.s3.amazonaws.com/twitter-a.png)](
* 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
* Basic SVG support (see "Limitations" below)

## Requirements

* PHP version 5.4.0 or higher
* PHP version 7.1 or higher
* DOM extension
* GD 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:
Expand All @@ -68,13 +70,13 @@ https://github.com/dompdf/dompdf/wiki/Requirements
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
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](https://github.com/dompdf/dompdf/wiki/About-Fonts-and-Character-Encoding)
for more information on how to use fonts.

The [DejaVu TrueType fonts](http://dejavu-fonts.org) have been pre-installed
The [DejaVu TrueType fonts](https://dejavu-fonts.github.io/) 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:
Expand Down Expand Up @@ -102,8 +104,9 @@ require 'vendor/autoload.php';

### Download and install

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

* You can download stable copies of dompdf from
https://github.com/dompdf/dompdf/releases
* Or download a nightly (the latest, unreleased code) from
Expand All @@ -117,35 +120,38 @@ and helper functions in your PHP:
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:
From the command line, switch to the directory where dompdf will
reside and run the following commands:

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

git clone https://github.com/PhenX/php-font-lib.git lib/php-font-lib
cd lib/php-font-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
```

Require dompdf, libraries, and helper functions in your PHP:
git checkout v0.3.2
cd ..

```php
require_once 'dompdf/lib/html5lib/Parser.php';
require_once 'dompdf/lib/php-font-lib/src/FontLib/Autoloader.php';
require_once 'dompdf/lib/php-svg-lib/src/autoload.php';
require_once 'dompdf/src/Autoloader.php';
Dompdf\Autoloader::register();
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](https://github.com/dompdf/utils/blob/master/autoload.inc.php).

## Quick Start

Just pass your HTML in to dompdf and stream the output:
Expand Down Expand Up @@ -187,25 +193,46 @@ or at run time
use Dompdf\Dompdf;

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

See [Dompdf\Options](src/Options.php) 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 (`$dompdf->set_option('isHtml5ParserEnabled', true);`)
parser at runtime (`$options->setIsHtml5ParserEnabled(true);`)
or run your HTML through a HTML validator/cleaner (such as
[Tidy](http://tidy.sourceforge.net) or the
[W3C Markup Validation Service](http://validator.w3.org)).
* Large files or large tables can take a while to render.
* CSS float is in development and may not produce the desired result
* 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:
```php
$html = '<img src="data:image/svg+xml;base64,' . base64_encode($svg) . '" ...>';
```
Watch https://github.com/dompdf/dompdf/issues/320 for progress

---

[![Donate button](https://www.paypal.com/en_US/i/btn/btn_donate_SM.gif)](http://goo.gl/DSvWf)

*If you find this project useful, please consider making a donation. Any funds donated will be used to help further development on this project.)*
*If you find this project useful, please consider making a donation.
Any funds donated will be used to help further development on this project.)*
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$Format:<%h>$
$Format:<%h>$
32 changes: 22 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,35 @@
}
],
"autoload": {
"psr-4" : {
"Dompdf\\" : "src/"
"psr-4": {
"Dompdf\\": "src/"
},
"classmap" : ["lib/"]
"classmap": [
"lib/"
]
},
"autoload-dev": {
"psr-4": {
"Dompdf\\Tests\\": "tests/"
}
},
"require": {
"php": ">=5.4.0",
"ext-gd": "*",
"php": "^7.1 || ^8.0",
"ext-dom": "*",
"ext-mbstring": "*",
"phenx/php-font-lib": "0.5.*",
"phenx/php-svg-lib": "0.3.*",
"ar-php/ar-php": "^1.0"
"phenx/php-font-lib": "^0.5.2",
"phenx/php-svg-lib": "^0.3.3"
},
"require-dev": {
"phpunit/phpunit": "4.8.*",
"squizlabs/php_codesniffer": "2.*"
"phpunit/phpunit": "^7.5 || ^8 || ^9",
"squizlabs/php_codesniffer": "^3.5",
"mockery/mockery": "^1.3"
},
"suggest": {
"ext-gd": "Needed to process images",
"ext-imagick": "Improves image processing performance",
"ext-gmagick": "Improves image processing performance",
"ext-zlib": "Needed for pdf stream compression"
},
"extra": {
"branch-alias": {
Expand Down
Loading

0 comments on commit db54049

Please sign in to comment.