我正在尝试将pdf文档与php合并,并且已经搜索了很多并尝试了一些解决方案。似乎最常见的是使用
FPDI
图书馆和一个小班级
PDF-Merger
.
但问题是
是指图书馆是依附于其他图书馆和其他图书馆的。安装示例主要是如何使用composer进行安装。但我想能够合并一个网站的pdf文件,而不是使用作曲家。这似乎很难实现。
由于
manual
,如果我不想使用composer,唯一要做的就是将此代码作为库的安装写入您的代码:
require_once('path/to/src/autoload.php');
当然,有正确的路径。但不,那对我不起作用。找不到fpdi类。如果你再看一下手册,你会看到这个警告:
别忘了之前安装fpdf、tcpdf或tfpdf!
所以我手动下载了这三个库,而且如果没有composer,这些库很难安装。却仍然在这混乱中蹒跚而行。我在pdfmerger.php文件中从
use fpdi\FPDI;
到
\setasign\Fpdi\Fpdi
. 现在找到了fpdi类。但还是会出错。
让我给你看看目前的情况。
这是我当前的代码:
require_once get_stylesheet_directory().'/classes/fpdf/fpdf.php';
require_once get_stylesheet_directory().'/classes/tfpdf/tfpdf.php';
require_once get_stylesheet_directory().'/classes/tcpdf/src/Output.php';
require_once get_stylesheet_directory().'/classes/tcpdf/src/MetaInfo.php';
require_once get_stylesheet_directory().'/classes/tcpdf/src/ClassObjects.php';
require_once get_stylesheet_directory().'/classes/tcpdf/src/Tcpdf.php';
require_once get_stylesheet_directory().'/classes/FPDI/src/autoload.php';
require_once get_stylesheet_directory().'/classes/FPDI/src/Fpdi.php';
require_once get_stylesheet_directory().'/classes/PDFMerger/PDFMerger.php';
$pdf = new \Clegginabox\PDFMerger\PDFMerger;
$pdf->addPDF('path/to/file1.pdf', 'all', 'P');
$pdf->addPDF('path/to/file2.pdf', 'all', 'P');
$pdf->merge();
?>
以下是浏览器中的错误消息:
注意:未定义的索引:w in
/主页/public_html/wp content/themes/my theme/classes/pdfmerger/pdfmerger.php
在线85
注意:未定义的索引:h in
/主页/public_html/wp content/themes/my theme/classes/pdfmerger/pdfmerger.php
在线85
注意:未定义的索引:w in
/主页/public_html/wp content/themes/my theme/classes/pdfmerger/pdfmerger.php
在线85
注意:未定义的索引:h in
/主页/public_html/wp content/themes/my theme/classes/pdfmerger/pdfmerger.php
在线85
致命错误:未捕获异常:fpdf错误:某些数据已经
已输出,无法发送PDF文件
/home/public_html/wp content/themes/my theme/classes/fpdf/fpdf.php:271
堆栈跟踪:0
/home/public_html/wp content/themes/my theme/classes/fpdf/fpdf.php(1063):
fpdf->错误('某些数据有…。')1
/home/public_html/wp content/themes/my theme/classes/fpdf/fpdf.php(999):
fpdf->_checkoutput()2
/home/public_html/wp content/themes/my theme/classes/pdfmerger/pdfmerger.php(107):fpdf->输出('i','newfile.pdf')\3
/home/public_html/wp content/themes/my theme/functions.php(269):
clegginabox\pdfmerger\pdfmerger->合并()4
/home/public_html/wp includes/class wp hook.php(286):
CDON掼U WOOMerce掼U加载('')5
/home/public_html/wp includes/cla
在里面
/主页/public_html/wp content/themes/my theme/classes/fpdf/fpdf.php
在线271
$fpdi->AddPage($fileorientation, array($size['w'], $size['h']));
我的意思是,我认为把所有这些依赖项都合并到pdf中有点夸张。真的需要这个吗?如果是的话,我的装置怎么了?