- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我已经创建了使用 TCPDF 制作页面的类。
我需要将 HTML 转换为 pdf,因此我使用了 writeHTML
和 AcceptPageBreak()
。
$html
是动态改变的,可能很长。
class MY_TCPDF extends TCPDF{
public function makePage($html){
$head_image="header.jpg";
$this->SetMargins(PDF_MARGIN_LEFT, 70, PDF_MARGIN_RIGHT);
$this->setPrintHeader(false);
$this->AddPage();
// get the current page break margin
$bMargin = $this->getBreakMargin();
// get current auto-page-break mode
$auto_page_break = $this->getAutoPageBreak();
// disable auto-page-break
$this->SetAutoPageBreak(false, 0);
// set bacground image
$img_file = $head_image;
$this->Image($img_file, 0, 0, 210, 68, '', '', '', false, 300, '', false, false, 0);
// restore auto-page-break status
//$this->SetAutoPageBreak($auto_page_break, PDF_MARGIN_BOTTOM);
// set the starting point for the page content
$this->setPageMark();
$this->writeHTML($html, true, false, true, false, '');
$this->lastPage();
ob_start();
//Close and output PDF document
$this->Output('my.pdf', 'I');
ob_end_flush();
}
public function AcceptPageBreak() {
$this->SetMargins(PDF_MARGIN_LEFT, 10, PDF_MARGIN_RIGHT);
$this->AddPage();
return false;
}
}
问题是我生成了 PDF,但 PDF 的末尾总是有一个额外的空白页。
我试过使用 $this->delete($this->getPage())
,但它只删除了最后一页有内容的页面,多余的空白页仍然存在。这似乎 writeHTML
会在它之后创建一个分页符。
如何防止这个额外的空白页?
最佳答案
我遇到了同样的问题:我修复了它:
class TCPDFextended extends \TCPDF {
public function Output($name = 'doc.pdf', $dest = 'I')
{
$this->tcpdflink = false;
return parent::Output($name, $dest);
}
}
关于php - TCPDF如何防止额外的空白页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22600329/
我相信 TCPDF 中没有本地方法来创建阴影。我有什么想法可以用其他方法创造这样的效果吗?我首先考虑在每个边缘(对于矩形)旁边创建一个小渐变,但发现没有办法创建具有不同 Alpha channel 的
我已经通读了之前关于该主题的主题,但都是陈旧的、未回答的和/或关于创建自定义字体的更具体的内容。 在 TCPDF 中: $pdf->SetFont('times', '', 10); 我创建的 pdf
在 TCPDF 中有 GetCellHeight()用于测量细胞的高度。 如何测量 TCPDF 中字符串(或字符串块)的长度或宽度? 最佳答案 获取字符串长度的方法是 GetStringWidth()
我正在设置 tcpdf 来为客户即时生成发票,但是当我添加图像时,边框从我的表格中消失了。这是代码: /* if ($status == "Paid") { $pdf->Image("/wp-
我正在使用 TCPDF 生成 pdf。我可以使用 SetMargins($left, $top, $right = -1, $keepmargins = false) 为左、上和右设置边距,但不能为底
我正在使用 TCPDF 生成 pdf。我可以使用 SetMargins($left, $top, $right = -1, $keepmargins = false) 为左、上和右设置边距,但不能为底
从版本 5.9 开始,我还没有找到控制 TCPDF 的 MultiCell 中行距的方法。我也没有找到任何有助于通过使用 Cell 来模拟相同行为的方法,例如返回不适合 Cell 宽度的文本部分的方法
我正在努力了解 header 函数在 tcpdf 中的工作方式。 是否可以将 $pdf->writeHTML 用于标题? http://www.tcpdf.org/examples/example_0
为了创建自定义页眉和页脚,我使用了 TCPDF 的 header()和 footer()函数,但是当我尝试使用函数 $this->image() 在标题中包含图像时, 无法显示图像。文档中的其他图像工
我正在使用 tcpdf 用 PHP 生成 PDF 文件,并且以 .svg 文件的形式嵌入 SVG 图像没有问题,其中包含表示图像的 XML 标记。但是,我希望能够使用该 XML,例如作为 PHP 字符
关于此的主题有很多,但没有一个能解决我的问题。我想做的很简单 - 生成一个条形图,然后将该图嵌入到一个 pdf 文件中,我将使用名为 TCPDF 的库生成该文件。 . 我使用 TCPDF 生成 HTM
第一张图片显示了使用 TCPDF 时的标准 header 布局: 我想做的是右对齐文本,如下所示,但我无法弄清楚如何做到这一点: 请大家给点建议!谢谢。 最佳答案 实现此目的的一种方法是使用 writ
我花了一个多小时研究这个问题,但似乎找不到答案。 我在 TCPDF 中使用 writeHTMLCell 。使用 writeHTMLCell 时,我需要一些文本以适合特定区域。 我见过一个例子here
我正在使用 TCPDF 从 HTML 代码生成 PDF,但无法正确呈现某些 HTML 特殊字符。这是我的准系统代码: require_once('../libraries/tcpdf_6_0_020/
我有以下 svg 文件: http://jsfiddle.net/wptn28c5/ 呈现: 但是,通过使用 tcpdf ($pdf->imageSVG()) 我得到一个呈现的 pdf 文件: 最佳
如何导入现有 pdf文件到新创建的 pdf使用 TCPDF? 所以假设我目前正在做发票部分。一旦用户点击打印发票,我将开始收集数据,然后创建一个 PDF使用 TCPDF .但是,如果可用,我需要“附加
我有以下 tcpdf 代码: SetCreator(PDF_CREATOR); $pdf->SetAuthor('Stimart'); $pdf->SetTitle('test
有谁知道如何使用 PHP TCPDF 导出 PDF/X-1a:2001 PDF 文件图书馆。我研究了很多,但找不到解决方案。有人请指教。解决方案需要在 PHP 中。 最佳答案 我不是 TCPDF 方面
我有一个基于数据生成 PDF 文件的网站。 我在一个免费的虚拟主机上试过了,没问题,但是当我把它上传到我的服务器时,我得到了这个错误: TCPDF 错误:无法打开图像文件:/var/www/html/
我正在使用 TCPDF 来签署 PDF,但是在运行 example 52 时我收到此错误: Warning: openssl_pkcs7_sign() [function.openssl-pkcs7-
我是一名优秀的程序员,十分优秀!