tranvantri/pdf-to-html
Composer 安装命令:
composer require tranvantri/pdf-to-html
包简介
This PHP class can convert your pdf files to html using poppler-utils.
关键字:
README 文档
README
This PHP class can convert your pdf files to html using poppler-utils.
Thanks
Big thanks Mochamad Gufron (mgufrone)! I did a packet based on its package (https://github.com/mgufrone/pdf-to-html).
Important Notes
Please see how to use below.
Installation
composer require tranvantri/pdf-to-html
Requirements
1. Install Poppler-Utils
Debian/Ubuntu
sudo apt-get install poppler-utils
Mac OS X
brew install poppler
Windows
For those who need this package in windows, there is a way. First download poppler-utils for windows here http://blog.alivate.com.au/poppler-windows/. And download the latest binary.
After download it, extract it.
2. We need to know where is utilities
Debian/Ubuntu
$ whereis pdftohtml pdftohtml: /usr/bin/pdftohtml $ whereis pdfinfo pdfinfo: /usr/bin/pdfinfo
Mac OS X
$ which pdfinfo /usr/local/bin/pdfinfo $ which pdftohtml /usr/local/bin/pdfinfo
Windows
Go in extracted directory. There will be a directory called bin. We will need this one.
3. PHP Configuration with shell access enabled
Usage
Example:
<?php // if you are using composer, just use this include 'vendor/autoload.php'; // initiate $pdf = new \TvT\PdfToHtml\Pdf('test.pdf', [ 'pdftohtml_path' => '/usr/bin/pdftohtml', 'pdfinfo_path' => '/usr/bin/pdfinfo' ]); // example for windows // $pdf = new \TvT\PdfToHtml\Pdf('test.pdf', [ // 'pdftohtml_path' => '/path/to/poppler/bin/pdftohtml.exe', // 'pdfinfo_path' => '/path/to/poppler/bin/pdfinfo.exe' // ]); // get pdf info $pdfInfo = $pdf->getInfo(); // get count pages $countPages = $pdf->countPages(); // get content from one page $contentFirstPage = $pdf->getHtml()->getPage(1); // get content from all pages and loop for they foreach ($pdf->getHtml()->getAllPages() as $page) { echo $page . '<br/>'; }
Full list settings:
<?php $fullSettings = [ 'pdftohtml_path' => '/usr/bin/pdftohtml', // path to pdftohtml 'pdfinfo_path' => '/usr/bin/pdfinfo', // path to pdfinfo 'generate' => [ // settings for generating html 'singlePage' => false, // we want separate pages 'imageJpeg' => false, // we want png image 'ignoreImages' => false, // we need images 'zoom' => 1.5, // scale pdf 'noFrames' => false, // we want separate pages ], 'clearAfter' => true, // auto clear output dir (if removeOutputDir==false then output dir will remain) 'removeOutputDir' => true, // remove output dir 'outputDir' => '/tmp/'.uniqid(), // output dir 'html' => [ // settings for processing html 'inlineCss' => true, // replaces css classes to inline css rules 'inlineImages' => true, // looks for images in html and replaces the src attribute to base64 hash 'onlyContent' => true, // takes from html body content only ] ]
tranvantri/pdf-to-html 适用场景与选型建议
tranvantri/pdf-to-html 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 544 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 12 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「PDF-to-HTML」 「tranvantri」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 tranvantri/pdf-to-html 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tranvantri/pdf-to-html 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 tranvantri/pdf-to-html 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
统计信息
- 总下载量: 544
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-12-13