vsitnikov/pdflib
Composer 安装命令:
composer require vsitnikov/pdflib
包简介
Current Release of PDFlib provide you methods to convert PDF to Images as well as Images to PDF.
关键字:
README 文档
README
PDFlib is a project which enables you to interact with PDFs, Current Release provide you methods to convert PDF to Images as well as Images to PDF, future releases will included more functions to interact with PDF files
This project is an initiative of Treinetic (Pvt) Ltd, Sri Lanka. contact us via info@treinetic.com and get your project done by the experts.
Requirements
You should have Ghostscript >= 9.16 installed and configured.
Install
The package can be installed via composer:
$ composer require vsitnikov/pdflib
Usage
Converting a PDF to set of images.
$pdflib = new vsitnikov\PDFLib\PDFLib(); $pdflib->setPdfPath($pdf_file_path); $pdflib->setOutputPath($folder_path_for_images); $pdflib->setImageFormat(\vsitnikov\PDFLib\PDFLib::$IMAGE_FORMAT_PNG); $pdflib->setDPI(300); $pdflib->setPageRange(1,$pdflib->getNumberOfPages()); $pdflib->setFilePrefix('page-'); // Optional $pdflib->convert();
Alternatively using chaining:
$files = (new vsitnikov\PDFLib\PDFLib()) ->setPdfPath($pdf_file_path) ->setOutputPath($folder_path_for_images) ->setImageFormat(\vsitnikov\PDFLib\PDFLib::$IMAGE_FORMAT_PNG) ->setDPI(300) ->setPageRange(1,$pdflib->getNumberOfPages()) ->setFilePrefix('page-') // Optional ->convert();
Making a PDF from set of images
$pdflib = new vsitnikov\PDFLib\PDFLib(); $imagePaths = ["images-1.jpg","images-2.jpg"]; $pdflib->makePDF($destination_pdf_file_path,$imagePaths);
If in anycase code throws '**** Unable to open the initial device, quitting.' this type of error that means program can't create temporary files because of a permission problem, this error only comes in the Linux or Mac Oparating systems so Please check the apache log and provide necessay permissions
Other useful methods
You can get the total number of pages in the pdf:
$pdfBox->getNumberOfPages(); //returns the number of pages in the pdf $pdfBox->setPageRange(1,2); // allows you to convert only few pages in the PDF Document $pdfBox->setImageQuality(95); // allows you to tell the quality you expect in the output Jpg file (only jpg) $pdfBox->setDPI(300); //setting the DPI (Dots per inch) of output files $pdfLib->setImageFormat(\vsitnikov\PDFLib\PDFLib::$IMAGE_FORMAT_PNG,$dDownScaleFactor=null); //this will set the output image format, default it is jpg, but I recommend using pdf to png because it seems it is faster /* $dDownScaleFactor=integer This causes the internal rendering to be scaled down by the given (integer <= 8) factor before being output. For example, the following will produce a 200dpi output png from a 600dpi internal rendering: gs -sDEVICE=png16m -r600 -dDownScaleFactor=3 -o tiger.png\examples/tiger.png Read More : http://ghostscript.com/doc/current/Devices.htm */
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Tests
- Make sure to run all the tests and see all of them are pssing before sumbitting a pull requests
How to run Tests ?
composer install
vendor/bin/phpunit
Credits
License
The MIT License (MIT). Please see License File for more information.
vsitnikov/pdflib 适用场景与选型建议
vsitnikov/pdflib 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 36 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 03 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「convert」 「ghostscript」 「PHP wrapper」 「Imal hasaranga」 「pdf to images」 「images to pdf」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 vsitnikov/pdflib 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vsitnikov/pdflib 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 vsitnikov/pdflib 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Provides a simple decimal/roman number converter
A library that provides a simple infrastructure to create your own converters and to perform any conversion you want
Bug-fixed and updated version of Meyfarth/Ghostscript-PHP script
Convert xml to array
PHP Wrapper for Ghost Script
Convert doctrine dbal query result to dto
统计信息
- 总下载量: 36
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-03-07