- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我的服务器上有一堆 pdf,下载时需要在每一页上附加文本。我正在使用 fpdf 尝试打开文件,将文本附加到每个页面,关闭文件并提供给浏览器。
$pdf = new FPDI();
$pdf->setSourceFile($filename);
// import page 1
$tplIdx = $pdf->importPage(1);
//use the imported page and place it at point 0,0; calculate width and height
//automaticallay and ajust the page size to the size of the imported page
$pdf->useTemplate($tplIdx, 0, 0, 0, 0, true);
// now write some text above the imported page
$pdf->SetFont('Arial', '', '13');
$pdf->SetTextColor(0,0,0);
//set position in pdf document
$pdf->SetXY(20, 20);
//first parameter defines the line height
$pdf->Write(0, 'gift code');
//force the browser to download the output
$pdf->Output('gift_coupon_generated.pdf', 'D');
header("location: ".$filename);
目前这只是试图在 pdf 上的任何位置放置一些文本并保存它,但我收到错误
FPDF error: You have to add a page first!
如果我能做到这一点,那么我需要它将文本附加到文档中的每一页,而不仅仅是 1 页,阅读文档后不确定如何执行此操作
最佳答案
尝试跟随
require_once('fpdf.php');
require_once('fpdi.php');
$pdf =& new FPDI();
$pdf->AddPage();
使用这个页面作为模板,然后
$pdf->setSourceFile($filename);
// import page 1
$tplIdx = $pdf->importPage(1);
//use the imported page and place it at point 0,0; calculate width and height
//automaticallay and ajust the page size to the size of the imported page
$pdf->useTemplate($tplIdx, 0, 0, 0, 0, true);
如果有错误请告诉我
关于php - 使用fpdf修改php中已有的pdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12510117/
我有一个从帖子表单生成的 pdf (fpdf)。我希望 pdf 在新选项卡和/或窗口中打开,提示用户保存 pdf。我猜我需要将输出保存为字符串 $data=$pdf->Output("OfficeFo
我正在使用 Python 3.8.5、conda 4.10.3 和 FPDF2 2.3.1 当我尝试导入包时,出现以下错误: 输入: from fpdf import FPDF 响应: -------
在我的应用程序中,PDF 在网页中打开,在下面的示例中,当用户单击 Logo.png 时,它被重定向到同一页面中的 FPDF 站点,但我想在新窗口中打开链接,而不是在同一个窗口中打开,因此用户打开了
我使用了 fpdf 库并根据 fpdf 的官方文档使用它。 我想在我的文件中使用标题但不能使用它,下面是我的代码。请纠正我的错误,为什么标题没有出现.. 这是我的代码: SetFont('Arial'
所以我想用 php 修改一个 pdf 模板。 我环顾四周,发现大多数人都使用 FPDI,于是我试了一下。 所以我做的是 include('pdf/fpdf.php'); include('pdf/fp
对于我的项目,我必须生成一个 PDF 文件。Stackoverflow 告诉我使用 FPDF。所以,我按照教程进行操作,但它似乎不起作用。 public function makePdf(Reques
我无法在关于同一主题的几篇文章中找到我的问题的答案,这就是为什么我将在这里提出更具体的问题。 我的问题是关于 wkhtmltopdf 和 fpdf。我需要其中之一来创建 1 页发票(真正的基本设计)和
为了生成 PDF 发票,我使用 fpdf lib 并将重复文本存储在 mySQL 数据库中。 当我将此文本存储在一个简单文件中时,我需要将其保存为 Latin1 编码,因为 fpdf 使用 Latin
好吧,我正在开发漫画(日本漫画)下载器。日本漫画可以在线获取,但你只能阅读,如果你想下载它们,你必须通过右键单击blah blah blah开始保存图像文件... 所以,我正在开发一个替代漫画下载器,
我有一个 PDF 文件,我想用 FDI/FPDF 添加一个新页面 Fatal error: Uncaught Exception: FPDF error: Incorrect output desti
我们如何以相同的高度显示具有不同内容量的 fpdf 多单元格 最佳答案 很好的问题。 我通过遍历行中的每个数据单元格来解决它,这些数据单元格将是多单元格并确定 最大高度所有这些细胞。这发生在您创建行中
我已经四处搜寻,发现这个问题非常普遍,但似乎找不到正确和直接的答案。我正在使用FPDF,并且我想使用MultiCell()生成表,因为我需要它的换行属性。尝试使用Cell(),但无法读取换行符。 $c
我一直在尝试让 php 发送一封附有 PDF 的电子邮件,我到处寻找并发现了这篇文章 Email PDF Attachment with PHP Using FPDF . 我尝试了解决方案,但仍然没有
谁能向我解释一下 FPDF 中的这个函数是如何工作的?使用以下代码,我似乎无法从中获得任何颜色: function Header() { // Logo $th
我正在从 html 表单创建 PDF 页面,所以我的 php 看起来像这样(例如): $pdf->Cell(0,0,$_POST['teacher_name'],0,2,'C'); 我可以定义该变量
我写了下面的代码来创建一个多单元格的表 $this->Cell(25, 25, "SR.No.", 'LTRB', 0, 'L', true); $this->Cell(60, 25, "CH
下面代码中的变量“输出”是几段文本,我正在尝试使用 FPDF 将其全部写入 pdf。但是,它只写入一行。我如何让它包含换行符。例如,文本的多个位置都有“\n”,但它被忽略了。谢谢。 dummytext
我需要创建具有背景颜色的单元格,但我使用的是示例: $pdf->SetFillColor(135,206,235); $pdf->Rect(9, 52, 190, 7, 'F'); 这个例子的问题是,
我正在使用 FPDI 和 FPDF 在现有 PDF 之上叠加新文本。它使用 useTemplate() 方法来实现这一点。 我遇到的问题 - 它只将模板应用于第一页。如果文本很长,它将换行到第二页,使
通过使用 FPDF (multiCell),我无法为一个简单的单词应用不同的标签。 举个例子: Sample 最后,它仅以下划线样式(最新的)以 PDF 形式显示。有没有可能将它们结合起来? 最佳答
我是一名优秀的程序员,十分优秀!