- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在使用 php 的 dompdf 库从 HTML 模板生成 PDF 报告。在该 html 模板中有一个目录部分。生成 PDF 时,我需要更新目录的页码。有谁知道我如何在 php 的 dompdf 库中实现这一点?
提前致谢。
最佳答案
我已经在 Drupal 中实现了这一点,我猜它也适用于其他 php 开源和框架。我将这段代码保存在脚本标签中
$GLOBALS['entity_page'][] = $pdf->get_page_number();
在存储页码的模板中。 模板的扩展名为 tpl.php现在在模块中在我添加了其他导出代码之后……
$canvas = $dompdf->get_canvas();
$font = Font_Metrics::get_font("helvetica", "normal");
$canvas->page_text(520, 805, "Page {PAGE_NUM}", $font, 9, array(0.4, 0.4, 0.4));
foreach ($GLOBALS['entity_page'] as $key => $val) {
$GLOBALS["entity_val"] = 0;
$GLOBALS["entity_y"] = 110;
$canvas->page_script('if($PAGE_NUM == 3 && $PAGE_NUM < 4){
$font = Font_Metrics::get_font("helvetica", "normal");
$x = 380;
$y = $GLOBALS["entity_y"];
$pdf->text($x, $y, "-------------------------".$GLOBALS["entity_page"][$GLOBALS["entity_val"]]."", $font, 12, array(0, 0, 0, 0.8));
$GLOBALS["entity_y"] = $GLOBALS["entity_y"] + 33;
$GLOBALS["entity_val"] = $GLOBALS["entity_val"] + 1;
}');
}
$pdf->text 这部分添加页码,在 y 轴位置上以恒定增量增加。其他全局变量 entity_y 和 entity_val 用于存储值。
关于php - 如何使用 dompdf 生成目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/692060/
我正在尝试使用 dompdf 生成 pdf,如何在浏览器的新选项卡中打开 pdf?就像,我单击 PDF 的链接,它应该在新选项卡中打开,而不是自动保存。我想让用户在第一次看到文件后选择保存文件。我怎么
我的 DOMPDF 有问题。 我正在尝试使用 DOMPDF 生成一个表格。 错误信息: The row #1 could not be found 完整的错误报告: > Fatal error
我将 DOMPDF 与 Laravel-dompdf 一起使用,经过数小时的研究后,我找不到能够渲染我的图像的解决方案。我已经提到了这些问题: DomPDF: Image not readable o
我在laravel 5.5和bootstrap css中使用barryvdh/laravel-dompdf(通过小的调整重命名为pdf.css)以pdf格式生成报告 这是我从报告 View 中调用 c
当使用自定义字体生成我的 PDF 并尝试像这样流式传输时:$pdf = PDF::loadView( '/pdfs/invoice',$data); return $pdf->stream();本地环
我正在使用 Bamboo invoice 作为发票生成器,我正在尝试自定义发票模板,但无论我做什么,字体似乎都无法调整。 目前我有 body { margin: 0.5in; font-family:
在 HTML 中形成的表 3 。每张纸都是一张 table 。我们需要一些东西来转换为 pdf,最后一片叶子在风景中!使用肖像它可以工作,以及如何制作相册的其中一张......我不明白...... 最
我有成功的 html 到 pdf 转换,但没有特殊字符。 下面只是我试图显示的一个特殊字符,当我将它简单地放在一个 html 文档中时,它会显示在我的 Mac 上的浏览器中。 (但不是在我的 wi
我目前正在尝试使用 Wordpress 和(最新版本的)dompdf,遇到了一个关于格式的恼人问题。 我的问题:生成的第二页似乎没有考虑主要内容的上边距,导致与我的 Logo 重叠。您可以查看生成的
我目前正在尝试使用 Wordpress 和(最新版本的)dompdf,遇到了一个关于格式的恼人问题。 我的问题:生成的第二页似乎没有考虑主要内容的上边距,导致与我的 Logo 重叠。您可以查看生成的
我尝试使用 dom pdf 创建价格标签。价格标签由一些 div 容器组成。其中一个容器具有最大高度,但这不起作用。因为如果我将此容器的文本更改为包含 200 个单词而不是 100 个单词的文本,则价
我正在安装 dompdf http://code.google.com/p/dompdf/ 一切顺利,但安装说明告诉我“编辑 dompdf_config.custom.inc.php(0.6 版)或
我正在使用 barryvdh/laravel-dompdf 包,我想创建一个可打印的页面。这是我的代码: $pdf = App::make('dompdf.wrapper'); $pdf->s
我在最新版本的 DOMPDF (0.6.0 Beta 3) 中遇到了一个非常奇怪的问题。我正在使用它为我网站上的客户创建发票。该设计要求表格单元格之间的边框为 1px。如果我使用黑色或 #000 作为
我正在尝试使用 Dompdf 从 html 文件生成漂亮的 pdf,但我无法画线 在每一页上。这是 php 文件的示例。 load_html($html); $dompdf->render(); $
我正在使用dompdf生成PDF。我已经从dompdf网站上获取了代码,将标题添加到pdf,并且可以使用,但是我想将标题放置在除第一页之外的所有页面上。有什么建议么? 最佳答案 您可以通过在第一页中出
我在 http://dompdf.github.com/ 上使用 DOMPDF 我正在努力如何设置整个页面的字体。在我制作的模板中,我在 CSS 中将字体设置为 Helvetica,但是当它生成 PD
使用的技术: PHP: v7.4 SilverStripe: v4.7 DomPDF: 1.0 在发布此内容之前,我确保能够遵循与此 DomPDF 相关的其他提示和文章,但未显示包含的图像,但图像仍然
我试图让表格在 DOMPDF 中 float 。我正在使用最新版本的 DOMPDF 0.6.0 beta2。在 dompdf_config.inc.php 中,我将 DOMPDF_ENABLE_CSS
我是 DOMPDF 的新手,我正在尝试使用 dompdf 将我表中未归档的所有记录打印为 pdf。这是以 pdf 格式打印 html 的代码。 table { font-family: ar
我是一名优秀的程序员,十分优秀!