- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试为现有的 PDF 文档添加水印,这个错误在过去两天一直困扰着我......
我的 FPDI 库位于 fpdi/src/中,fpdf 库位于/fpdf/
引发错误的文件是 Fpdi.php(第 27 行)。以下是前 30 行:
<?php
/**
* This file is part of FPDI
*
* @package setasign\Fpdi
* @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com)
* @license http://opensource.org/licenses/mit-license The MIT License
* @version 2.0.0
*/
namespace setasign\Fpdi;
use setasign\Fpdi\PdfParser\CrossReference\CrossReferenceException;
use setasign\Fpdi\PdfParser\Type\PdfIndirectObject;
use setasign\Fpdi\PdfParser\Type\PdfNull;
//use setasign\Fpdi\FpdfTpl;
/**
* Class Fpdi
*
* This class let you import pages of existing PDF documents into a reusable structure for FPDF.
*
* @package setasign\Fpdi
*/
class Fpdi extends FpdfTpl
{
use FpdiTrait;
这是我用来动态为 .pdf 文档添加水印的文件:
<?php
$fullPathToFile = $_GET['fileToWaterMark'];
require('rotation.php');
require_once('fpdf/fpdf.php');
require_once 'fpdi/src/fpdi.php';
require_once('fpdi/src/FpdfTpl.php');
class PDF_Rotate extends FPDI {
var $angle = 0;
function Rotate($angle, $x = -1, $y = -1) {
if ($x == -1)
$x = $this->x;
if ($y == -1)
$y = $this->y;
if ($this->angle != 0)
$this->_out('Q');
$this->angle = $angle;
if ($angle != 0) {
$angle*=M_PI / 180;
$c = cos($angle);
$s = sin($angle);
$cx = $x * $this->k;
$cy = ($this->h - $y) * $this->k;
$this->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm', $c, $s, -$s, $c, $cx, $cy, -$cx, -$cy));
}
}
function _endpage() {
if ($this->angle != 0) {
$this->angle = 0;
$this->_out('Q');
}
parent::_endpage();
}
}
//$fullPathToFile = "chinmay235.pdf";
class PDF extends PDF_Rotate {
var $_tplIdx;
function Header() {
global $fullPathToFile;
//Put the watermark
$this->Image('http://chart.googleapis.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World', 40, 100, 100, 0, 'PNG');
$this->SetFont('Arial', 'B', 50);
$this->SetTextColor(255, 192, 203);
$this->RotatedText(20, 230, 'Raddyx Technologies Pvt. Ltd.', 45);
if (is_null($this->_tplIdx)) {
// THIS IS WHERE YOU GET THE NUMBER OF PAGES
$this->numPages = $this->setSourceFile($fullPathToFile);
$this->_tplIdx = $this->importPage(1);
}
$this->useTemplate($this->_tplIdx, 0, 0, 200);
}
function RotatedText($x, $y, $txt, $angle) {
//Text rotated around its origin
$this->Rotate($angle, $x, $y);
$this->Text($x, $y, $txt);
$this->Rotate(0);
}
}
$pdf = new PDF();
$pdf->AddPage();
$pdf->SetFont('Arial', '', 12);
$pdf->Output();
?>
我对 PHP 相当熟练,但这个错误确实让我陷入了困境。如果需要更多信息,请告诉我,我会提供。
最佳答案
需要这样的类:
require_once('fpdf/fpdf.php');
require_once('fpdi/src/autoload.php');
然后将use\setasign\Fpdi\Fpdi;
添加到您的水印中,而不仅仅是use\setasign\Fpdi;
或使用正确的类名(包括完整的命名空间) ) 在你的类声明中。
关于php - FPDF/FPDI 错误 : Fatal error: Class 'setasign\Fpdi\FpdfTpl' not found in,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47292751/
我有一个从帖子表单生成的 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 形式显示。有没有可能将它们结合起来? 最佳答
我是一名优秀的程序员,十分优秀!