ncjoes/pdf-suite
Composer 安装命令:
composer require ncjoes/pdf-suite
包简介
A high level wrapper over Poppler-Php for PDF content extraction and conversion using Poppler utils
关键字:
README 文档
README
PDF Suite extracts and converts the contents of PDF files to various formats, including HTML and SVG using Poppler utils
Why Use PDF-Suite?
Many packages tagged as PDF converters are actually *->PDF converters, i.e from other formats to PDF. PDF Suite, on the other hand, provides a high level of abstraction over the PopplerPhp package, making it more easy to convert your PDF files into any of the formats supported by Poppler utils. These supported formats include:
- HTML
- JPG, PNG, TIFF
- PostScript (PS)
- Encapsulated PostScript (EPS)
- Scalable Vector Graphic (SVG)
- Plain Text
You can also use this package to split pdf files, combine pdf files, and detach embedded items from pdf files using PHP.
How to Install?
You can install this package using any of these 2 methods:
- Install it via Composer (ncjoes/pdf-suite on Packagist);
- Use the official Git repository (https://github.com/ncjoes/pdf-suite).
Then, require the vendor/autoload.php file to enable the autoloading mechanism provided by Composer. Otherwise, your application won't be able to find the classes of this Symfony component.
Finally, point the config settings to the location of Poppler utils binaries on your php server. See PopplerPhp installation notes for help with Poppler Utils installation.
How to Use?
Setup Poppler utils binaries location
NcJoes\PdfSuite\Config::setBinDirectory($dir);
Here are some examples.
<?php // if you are using composer, just use this use NcJoes\PdfSuite\PdfSuite; use NcJoes\PdfSuite\Config; //Configuration Config::setBinDirectory(__DIR__.'/../vendor/bin/poppler');//set up poppler binaries location Config::setOutputDirectory(__DIR__.'/results', true); //set main output directory Config::doCleanupOnExit(false); //set to true if you want output files to be deleted on script termination // Create PdfSuite instance $file = dirname(__FILE__).'\sources\test1.pdf'; $pdfSuite = new PdfSuite($file); //Pdf metadata $pdf_info = $pdfSuite->getPdfInfo(); //returns an associative array $authors = $pdf_info->getAuthors(); $number_of_pages = $pdf_info->getNumOfPages(); //...e.t.c. //PDF to HTML converter $htmlConverter = $pdfSuite->getPdfToHtmlConverter(); $htmlConverter->setPageRange(1, 16)->useDefaultSettings(); $htmlConverter->setOutputSubDir('testSinglePageConverterOption'); // returns a directory instance, a OOP model of a directory/folder containing the output files $directory = $htmlConverter->convert($htmlConverter::MODE_SINGLE_PAGE_PER_DOC); //other output mode options include //$converter::MODE_MULTI_PAGED_SINGLE_DOC //and //$converter::MODE_COMPLEX_DOCUMENT //PDF to JPEG converter $jpegConverter = $pdfSuite->getPdfToJpegConverter(); $jpegConverter->setPageRange(15, 33); $jpegConverter->convert(); // returns a directory instance //PDF to PNG converter $pngConverter = $pdfSuite->getPdfToPngConverter(); $pngConverter->setPageRange(15, 33); $pngConverter->convert(); // returns a directory instance //PDF to PostScript converter $psConverter = $pdfSuite->getPdfToPsConverter(); $psConverter->setPageRange(15, 33); $psConverter->convert(); // returns a directory instance //PDF to SVG converter $svgConverter = $pdfSuite->getPdfToSvgConverter(); $svgConverter->setPageRange(15, 33); $svgConverter->convert(); // returns a directory instance //You can also obtain the underlying NcJoes\PopplerPhp\PopplerUtil instance // and use it to further customize any of the converters $svgConverter = $pdfSuite->getPdfToSvgConverter(); $svgConverterUtil = $svgConverter->util(); $svgConverterUtil->utilOptions(); //returns an array of all available options for svgConverter $svgConverterUtil->setOption('key', 'value'); //etc ?>
License
The PDF Suite package is open-sourced software licensed under the MIT license.
Feedback & Contribute
Notify me of any issues, bugs, or improvements. Thanks 👍
ncjoes/pdf-suite 适用场景与选型建议
ncjoes/pdf-suite 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 275 次下载、GitHub Stars 达 8, 最近一次更新时间为 2016 年 10 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「pdf」 「pdf converter」 「Poppler-utils」 「PDF to HTML Converter」 「PDF to SVG Converter」 「PDF to JPG Converter」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ncjoes/pdf-suite 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ncjoes/pdf-suite 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ncjoes/pdf-suite 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Complete, Comprehensive and Flexible PHP wrapper for Poppler-utils
Tools to convert between .NET and PHP date formats
Encode integer IDs using a preset or customized symbol set
Complete, Comprehensive and Flexible PHP wrapper for Poppler-utils
Complete, Comprehensive and Flexible PHP wrapper for Poppler-utils
Complete, Comprehensive and Flexible PHP wrapper for Poppler-utils
统计信息
- 总下载量: 275
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-10-17





