- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
感谢 FPDF,我创建了一个 PDF 生成器,它使用来自 mysql 数据库的数据并且运行良好。页数可变。
然后我想向每个 PDF 添加一些从其他 PDF 文件导入的页面。添加页数和导入文件地址也是可变的。
它工作得很好,除了我的页脚不再出现。我想在每个页面上保留这个页脚,生成器创建的页面和导入的页面。谁能告诉我问题出在哪里?..
这是我的代码:
require_once('gpdf/fpdf.php');
require_once('gpdf/fpdi.php');
class PDF extends FPDI
{
function Header()
{
}
function Footer()
{
// Positionnement à 1,5 cm du bas
$this->SetY(-15);
// Police Arial italique 8
$this->SetFont('Arial','I',8);
// Numéro de page
$this->Cell(0,10,'Devis from MyCompany - Page '.$this->PageNo().'/{nb}'.' Paraphes :',0,0,'C');
}
}
// Instanciation de la classe dérivée
$pdf = new FPDI();
$pdf->AliasNbPages();
$pdf->AddPage();
// Here is page 1, you don't need the details
$pdf->AddPage();
// Here is page 2, some other pages can come too
// Then begins the importation
// get the page count
$pageCount = $pdf->setSourceFile('cgua/cgu_'.$customer['num'].'.pdf');
// iterate through all pages
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
// import a page
$templateId = $pdf->importPage($pageNo);
// get the size of the imported page
$size = $pdf->getTemplateSize($templateId);
// create a page (landscape or portrait depending on the imported page size)
if ($size['w'] > $size['h']) {
$pdf->AddPage('L', array($size['w'], $size['h']));
} else {
$pdf->AddPage('P', array($size['w'], $size['h']));
}
// use the imported page
$pdf->useTemplate($templateId);
}
$pdf->Output('devis.pdf','I');
我在 FPDI 的手册中没有找到关于如何保留我的页脚的解释......我确信很容易解决这个问题,我只是没有找到方法!
谢谢!
最佳答案
您创建了一个继承 FPDI 类的新类。这个新类 PDF 正确定义了 Footer 方法。但是随后您实例化了 FPDI 类,而不是 PDF 类。
只是改变
$pdf = new FPDI();
到
$pdf = new PDF();
这样您就可以实例化您的新类并查看新的 Footer 方法的结果。
关于php - 在 FPDI 中添加页脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31495537/
我正在尝试为现有的 PDF 文档添加水印,这个错误在过去两天一直困扰着我...... 我的 FPDI 库位于 fpdi/src/中,fpdf 库位于/fpdf/ 引发错误的文件是 Fpdi.php(第
我正在使用 FPDI 和 FPDF 在现有 PDF 之上叠加新文本。它使用 useTemplate() 方法来实现这一点。 我遇到的问题 - 它只将模板应用于第一页。如果文本很长,它将换行到第二页,使
我正在使用 FPDI 和 FPDF 在现有 PDF 之上叠加新文本。它使用 useTemplate() 方法来实现这一点。 我遇到的问题 - 它只将模板应用于第一页。如果文本很长,它将换行到第二页,使
我陷入了一个非常复杂的境地。我正在开发用于贺卡的 PHP Web 应用程序。 为此,我使用了一些 Linux 工具以及 TCPDF 和 FPDI。让我告诉你这一切是如何运作的: 有 4 页贺卡模板 P
我是 PHP 的新手,在插入多个页面时使用 FPDI 有点困难。 我有一个包含 3 页的 .pdf 文件。我最终将第 1 页保存为第 3 页中的一个单独页面,并且与我的代码一起使用,但那是因为我的代码
你好我正在使用 Fpdi 类在 pdf 文件上添加图像(在 PHP 中)(我从 github https://github.com/Setasign/FPDI 下载代码) 但是当我尝试实例化一个新的
我正在使用 FPDI 库将多个 pdf 文件合并为一个, 遵循此文档 https://manuals.setasign.com/fpdi-manual/v2/the-fpdi-class/ 我试过如下
感谢 FPDF,我创建了一个 PDF 生成器,它使用来自 mysql 数据库的数据并且运行良好。页数可变。 然后我想向每个 PDF 添加一些从其他 PDF 文件导入的页面。添加页数和导入文件地址也是可
如何在名为 FPDI 的 php 库中设置 UTF-8 编码? 这是图书馆:https://www.setasign.com/products/fpdi/manual/ 编码: $pdf = new
这看起来是最简单的事情,但我无法让它工作。 我需要将文本添加到多页 pdf 的第一页(可以是任意页数) 在两页 pdf 上使用此代码(没有 for 循环,仅使用 $pdf->importPage(2)
我正在使用以下代码向我现有的 PDF 文档添加一个新页面并保存它。 require('addons/fpdf.php'); require('addons/fpdi.php'); $pdf = new
我正在尝试学习如何使用 PHP 语言使用 FPDF 和 FPDI 编辑 PDF 文件。我有这个 sample PDF file我想插入一些值的地方。如果我要使用 FPDF 创建 PDF 文件,一切正常
我正在尝试使用 FPDI 导入现有 PDF 作为模板。该模板为横向格式。如果我将模板导入到新文档中,模板页面将以纵向形式插入,内容旋转 90 度。如果我的新文档是纵向的,则会显示完整内容,但如果新文档
因此,我正在使用 fpdi,版本 1.2 为文档中的每个页面添加一些小标记。这是我的代码: public static function markPdf($file, $text){ defi
我的任务是修改 PDF 并向其中添加图像,为此我使用了 FPDF 和 FPDI 库。其操作代码如下: AddPage(); //Set the source PDF file $pagecount =
我被困在工作中。我正在用 PHP 编码,我必须生成一个 PDF。我的问题是我必须创建卡片(相同尺寸的信用卡 85.6*54mm),我使用的是正确尺寸的模板,但页面仍然以 A4 格式生成。我可以在左上角
是否可以将 TCPDF 或 FPDI PDF 作为字符串提供?我有一个传入的 PDF 数组作为字符串,但我无法写入磁盘。我无法在文档中找到与此相关的任何内容。 如果没有,是否有有效的方法从内存或作为对
我刚刚跑了apt-get install libfpdi-php以及安装 Composer 并运行composer require setasign/fpdi-fpdf .所有三个操作似乎都很好地完成
我正在尝试使用 FPDI 合并两个文件我得到的错误是:'TCPDF 错误:文件已加密!',但是,文件未加密,至少文件可打印、可查看等,并且不需要密码。 我想合并两个文件: http://www.nps
我修改了这个堆栈问题:Applying watermarks on pdf files when users try to download the files但是我遇到了一个错误,虽然有一条评论说如
我是一名优秀的程序员,十分优秀!