analize/mpdf-analize
Composer 安装命令:
composer require analize/mpdf-analize
包简介
PHP library generating PDF files from UTF-8 encoded HTML
README 文档
README
mPDF is a PHP library which generates PDF files from UTF-8 encoded HTML.
It is based on FPDF and HTML2FPDF (see CREDITS), with a number of enhancements. mPDF was written by Ian Back and is released under the GNU GPL v2 licence.
⚠ If you are viewing this file on mPDF GitHub repository homepage or on Packagist, please note that the default repository branch is
developmentwhich can differ from the last stable release.
Objetivo desse fork foi a remoção da página em branco após o índice que criava segue passo a passo.
Adicione o pacote MpdfAnalize para que funcione a modificação:
composer require wendel-ulhoa/laravel-mpdf-analize
composer require analize/mpdf-analize
use Analize\LaravelMpdfAnalize\LaravelMpdfAnalizeWrapper;
/* Criando uma instância da classe LaravelMpdfAnalizeWrapper, biblioteca modificada para que possa retirar a página em branco após os índices. */
$mpdf = new LaravelMpdfAnalizeWrapper();
/* Obtendo a renderização do PDF utilizando o Mpdf e a separação por chuncks para não atingir o limite de backtrack */
$pdf = $mpdf->chunkLoadView('<!--chunk-->', 'view', [], [], $configs);
/* Remove a página em branco que era adicionada após os índices, (Caso queira que volte a fazer a mesma impressão é só comentar a linha abaixo.). */
$pdf->getMpdf()->deletePage(2, true);
Requirements
PHP versions and extensions
PHP >=5.6 <7.3.0is supported formPDF >= 7.0PHP 7.3is supported sincemPDF v7.1.7PHP 7.4is supported sincemPDF v8.0.4PHP 8.0is supported sincemPDF v8.0.10PHP 8.1is supported as ofmPDF v8.0.13PHP 8.2is supported as ofmPDF v8.1.3PHP 8.3is supported as ofmPDF v8.2.1PHP 8.4is supported as ofmPDF v8.2.5
PHP mbstring and gd extensions have to be loaded.
Additional extensions may be required for some advanced features such as zlib for compression of output and
embedded resources such as fonts, bcmath for generating barcodes or xml for character set conversion
and SVG handling.
Known server caveats
mPDF has some problems with fetching external HTTP resources with single threaded servers such as php -S. A proper
server such as nginx (php-fpm) or Apache is recommended.
Support us
Consider supporting development of mPDF with a donation of any value. Donation button can be found on the main page of the documentation.
Installation
Official installation method is via composer and its packagist package mpdf/mpdf.
$ composer require mpdf/mpdf
Usage
The simplest usage (since version 7.0) of the library would be as follows:
<?php require_once __DIR__ . '/vendor/autoload.php'; $mpdf = new \Mpdf\Mpdf(); $mpdf->WriteHTML('<h1>Hello world!</h1>'); $mpdf->Output();
This will output the PDF inline to the browser as application/pdf Content-type.
Setup & Configuration
All configuration directives can
be set by the $config parameter of the constructor.
It is recommended to set one's own temporary directory via tempDir configuration variable.
The directory must have write permissions (mode 775 is recommended) for users using mPDF
(typically cli, webserver, fpm).
Warning: mPDF will clean up old temporary files in the temporary directory. Choose a path dedicated to mPDF only.
<?php $mpdf = new \Mpdf\Mpdf(['tempDir' => __DIR__ . '/tmp']);
By default, the temporary directory will be inside vendor directory and will have write permissions from
post_install composer script.
For more information about custom temporary directory see the note on Folder for temporary files in the section on Installation & Setup in the manual.
If you have problems, please read the section on troubleshooting in the manual.
About CSS support and development state
mPDF as a whole is a quite dated software. Nowadays, better alternatives are available, albeit not written in PHP.
Use mPDF if you cannot use non-PHP approach to generate PDF files or if you want to leverage some of the benefits of mPDF over browser approach – color handling, pre-print, barcodes support, headers and footers, page numbering, TOCs, etc. But beware that a HTML/CSS template tailored for mPDF might be necessary.
If you are looking for state of the art CSS support, mirroring existing HTML pages to PDF, use headless Chrome.
mPDF will still be updated to enhance some internal capabilities and to support newer versions of PHP, but better and/or newer CSS support will most likely not be implemented.
Online manual
Online manual is available at https://mpdf.github.io/.
General troubleshooting
For general questions or troubleshooting please use Discussions.
You can also use the mpdf tag at Stack Overflow as the StackOverflow user base is more likely to answer you in a timely manner.
Contributing
Before submitting issues and pull requests please read the CONTRIBUTING.md file.
Unit Testing
Unit testing for mPDF is done using PHPUnit.
To get started, run composer install from the command line while in the mPDF root directory
(you'll need composer installed first).
To execute tests, run composer test from the command line while in the mPDF root directory.
Any assistance writing unit tests for mPDF is greatly appreciated. If you'd like to help, please
note that any PHP file located in the /tests/ directory will be autoloaded when unit testing.
analize/mpdf-analize 适用场景与选型建议
analize/mpdf-analize 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.03k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 05 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「pdf」 「utf-8」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 analize/mpdf-analize 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 analize/mpdf-analize 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 analize/mpdf-analize 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
tfpdf
Removes invalid UTF-8 characters from the given text
Country Flag Emoji for PHP
A collection of PHP multi-byte string functions that are not present in the mb_string extension.
Provides TCPDF integration for Symfony
Alfabank REST API integration
统计信息
- 总下载量: 1.03k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-only
- 更新时间: 2024-05-20