承接 ncjoes/pdf-suite 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

PDF-to-Html PDF-to-Images PDF-to-Text PDF-Splitter PDF-Combiner PDF-to-SVG

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:

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 我们能提供哪些服务?
定制开发 / 二次开发

基于 ncjoes/pdf-suite 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 275
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 9
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-10-17