silverstripe-australia/pdfrendition
最新稳定版本:2.1.1
Composer 安装命令:
composer require silverstripe-australia/pdfrendition
包简介
A module that makes use of the Flying Saucer XHTML renderer project to create PDFs from XHTML pages.
关键字:
README 文档
README
Maintainer Contact
- Marcus Nyeholt marcus@symbiote.com.au
- Nathan Glasl nathan@symbiote.com.au
Requirements
- SilverStripe 4.12+ || 5+
- Tidy (preferably the built in PHP tidy module, otherwise the commandline binary)
- Java 1.8 (the latest version this has been tested against)
- Important: earlier 1.7 versions cause the PDF to not load Cloudflare specific assets such as images and CSS
- Important: regardless of the version you end up using, make sure the PDF output is correct on the production server prior to go-live (please see the known issues section below)
Documentation
This module allows users to easily create complex PDF renditions of content by utilising HTML and CSS3 to define page layouts for printing. It provides a simple extension that adds a simple action for automatically generating PDF renditions of a page, and an API for developers to generate more specific PDF renditions.
Installation Instructions
composer require symbiote/silverstripe-pdfrendition
Usage Overview
- Add
Symbiote\PdfRendition\Extension\PdfControllerExtensionas an extension to PageController - Add $PdfLink in your template to insert a link to the PDF version of the page
- To customise the PDF layout, create a 'pdfrendition.css' file in your theme directory, link to it with your preferred method (@import, requirements, etc.) and add styles specifically for your pdf using the @print media query. See the github wiki for some examples of how to do some common PDF based things.
Known Issues / Troubleshooting
- Using HTTPS without a valid certificate can cause the PDF to not render correctly.
- Cloudflare can cause the PDF to not render correctly.
- This may be due to Java attempting to reference the assets (images and CSS), and being listed as a "bad browser".
- To resolve this, Cloudflare
Page Rulesneed to be added for those specific assets (or a general/*blanket rule) withBrowser Integrity Checkset toOff.
- To resolve this, Cloudflare
- This may also be due to the Java version (please see above).
- The PDF output can be tested by intercepting the render process locally and holding onto the
xhtmlfile generated prior to render. - Using this, replace the asset URLs with those you want to test and confirm (production for example).
- The Java Flying Saucer utility will retrieve assets and external sources via links contained in the
xhtmlsource. Ensure these links are fully formed, and are able to be retrieved from within the production server (i.e. outbound firewall restrictions or localised DNS/host definitions could cause issues).
- The Java Flying Saucer utility will retrieve assets and external sources via links contained in the
- Using this
/tmp/xhtml, the below should give you a correctly rendered PDF when run from within the production server. - If not, Cloudflare and/or Java are likely the issue.
- This may be due to Java attempting to reference the assets (images and CSS), and being listed as a "bad browser".
java -classpath '{project}/pdfrendition/thirdparty/xhtmlrenderer/flying-saucer-core-9.0.7.jar:{project}/pdfrendition/thirdparty/xhtmlrenderer/flying-saucer-pdf-9.0.7.jar:{project}/pdfrendition/thirdparty/xhtmlrenderer/itext-4.2.1.jar' org.xhtmlrenderer.simple.PDFRenderer '/tmp/xhtml' '/tmp/output.pdf'
- Make sure you don't define @font-face inside @media print.
Occasionally a page won't correctly render, throwing some kind of junk back to the browser as the PDF rendition process fails. Typically, this is caused by malformed XML being sent to the renderer; for this reason everything is first passed through HTML Tidy, however in some rare cases this can still not correctly convert the raw content.
In these cases, errors will be sent through to your error log files; it will indicate the temporary files that were created, so you should first check these for XML errors. If that does not work, you can also attempt to manually perform the conversion using commandline tidy and the commandline for the PDF rendition to see if there are more verbose errors available for debugging the problem.
silverstripe-australia/pdfrendition 适用场景与选型建议
silverstripe-australia/pdfrendition 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11.22k 次下载、GitHub Stars 达 17, 最近一次更新时间为 2015 年 07 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「pdf」 「silverstripe」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 silverstripe-australia/pdfrendition 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 silverstripe-australia/pdfrendition 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 silverstripe-australia/pdfrendition 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Analytics chooser extensions for site settings.
CitaNZ's SilverStripe picture object and field for SilverStripe 4
bootstrap select field module implementing http://silviomoreto.github.io/bootstrap-select/
Allows you to defined CMS form structure via config.yml
Provides TCPDF integration for Symfony
统计信息
- 总下载量: 11.22k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 17
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2015-07-06