mezhenko/dompdf
最新稳定版本:v0.6.3
Composer 安装命令:
composer require mezhenko/dompdf
包简介
DOMPDF is a CSS 2.1 compliant HTML to PDF converter
README 文档
README
dompdf is an HTML to PDF converter. At its heart, dompdf is (mostly) 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.
Check out the Demo and ask any question on StackOverflow or on the Google Groups
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)
- svg support (both inline and external)
- no dependencies on external PDF libraries, thanks to the R&OS PDF class
- inline PHP support
Requirements
- PHP 5.3+
- RSVG extension (for svg support)
- CAIRO extension (for svg support)
- DOM extension
- GD extension
Recommendations
- MBString extension: provides internationalization support. This extension is not enabled by default. dompdf has limited internationalization support when this extension is not enabled.
- opcache (OPcache, XCache, APC, etc.): improves performance
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).
Easy Installation
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 git submodule init git submodule update
Install with composer
To install with Composer, simply add the requirement to your composer.json
file:
{
"require" : {
"dompdf/dompdf" : "0.6.*"
}
}
And run Composer to update your dependencies:
$ curl -sS http://getcomposer.org/installer | php
$ php composer.phar update
Before you can use the Composer installation of DOMPDF in your application you must disable dompdf's default auto-loader, include the Composer autoloader, and load the dompdf configuration file:
// somewhere early in your project's loading, require the Composer autoloader // see: http://getcomposer.org/doc/00-intro.md require 'vendor/autoload.php'; // disable DOMPDF's internal autoloader if you are using Composer define('DOMPDF_ENABLE_AUTOLOAD', false); // include DOMPDF's default configuration require_once '/path/to/vendor/dompdf/dompdf/dompdf_config.inc.php';
Download and install
Download an 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/tags
- Or download a nightly (the latest, unreleased code) from http://eclecticgeek.com/dompdf
Limitations (Known Issues)
- not particularly tolerant to poorly-formed HTML input. To avoid any
unexpected rendering issues you should either enable the built-in HTML5
parser (via the
DOMPDF_ENABLE_HTML5PARSERconfiguration constant) or run your HTML through a HTML validator/cleaner (such as Tidy). - large files or large tables can take a while to render
- CSS float is not supported (but is in the works, enable it through the
DOMPDF_ENABLE_CSS_FLOATconfiguration constant). - If you find this project useful, please consider making a donation.
(Any funds donated will be used to help further development on this project.)
mezhenko/dompdf 适用场景与选型建议
mezhenko/dompdf 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9.43k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2014 年 12 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 mezhenko/dompdf 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mezhenko/dompdf 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 9.43k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: LGPL
- 更新时间: 2014-12-26