我为使用TCPDF创建的PDF创建了自定义标题。现在我想添加一个蓝色的线(大约2px宽),它贯穿页眉底部的页面,但不知道如何?TCPDF在标题页中添加行
3
A
回答
10
我相信你做这样的:
$style = array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 0, 0));
$pdf->Line(5, 10, 80, 30, $style);
下面是完整的例子
3
您还可以使用页面轴:
$pdf->Line(5, $pdf->y, $pdf->w - 5, $pdf->y);
但是,如果您正试图呈现一个颜色为<hr>
的html标签升需要调整TCPDF::DrawColor
(这摘录来自代码,增加了一个曲线图巴至一个数据报告的每行按$twidth
和$lengthmm
):
$htmlbar = '<hr style="width:' . $lengthmm . 'mm;">';
$oldDrawColor = $pdf->DrawColor;
$pdf->setDrawColor(121, 161, 46);
$pdf->MultiCell($twidth,'2',$htmlbar,0,'L',$fill,1,'','',true,0,true,false,4,'T',false);
$pdf->DrawColor = $oldDrawColor;
0
关键是要得到的x值对所述第二点。 这是我要做的事:
$pageWidth = $pdf->getPageWidth(); // Get total page width, without margins
$pageMargins = $pdf->getMargins(); // Get all margins as array
$headerMargin = $pageMargins['header']; // Get the header margin
$px2 = $pageWidth - $headerMargin; // Compute x value for second point of line
$p1x = $this->getX();
$p1y = $this->getY();
$p2x = $px2;
$p2y = $p1y; // Use same y for a straight line
$style = array();
$this->Line($p1x, $p1y, $p2x, $p2y, $style);
链接 TCPDF :: getMargins()
http://www.tcpdf.org/doc/code/classTCPDF.html#ae9bd660bf5b5e00eea82f1168cc67b5b
TCPDF :: getPageWidth()
http://www.tcpdf.org/doc/code/classTCPDF.html#a510ab21d6a373934bcd3bd4683704b7e
玩得开心!
2
我发现最简单的方法把线
$pdf->writeHTML("<hr>", true, false, false, false, '');
0
只需添加一些HTML:)
$html ='<hr>';
$pdf->writeHTML($html, true, false, true, false, '');
相关问题
- 1. 如何在tcpdf中添加页脚
- 2. 如何在tcpdf库中添加页脚
- 3. 添加页面在tcpdf不工作
- 4. TCPDF徽标标题
- 5. 如何在laravel tcpdf中添加自定义页眉和页脚?
- 6. TCPDF页脚如何添加列
- 7. TCPDF添加页面自动化
- 8. TCPDF:自动添加页面时的MultiCell
- 9. TCPDF和问题使用添加CSS
- 10. 如何在MDX中添加行标题?
- 11. 在TListView中添加2行标题?
- 12. 在TCPDF的第一页之前添加页面
- 13. 如何在TCPDF中添加图像
- 14. 如何在TCPDF文件中添加标头对齐
- 15. TCPDF/FPDF - 分页问题
- 16. TCPDF页边距问题
- 17. 在PHP中添加标题
- 18. 在godoc中添加标题
- 19. JTable不添加标题行
- 20. 添加标题行的GridView
- 21. 如何在TCPDF中删除标题和$ html之上的行?
- 22. 如何在GridView中的页码前添加页面标题
- 23. 在页面标题中添加页码 - magento
- 24. 如何在TCPDF中添加新行(<br>或\ n)?
- 25. 在页面加载时将页面标题添加为body类
- 26. Moodle加载白页TCPDF
- 27. 将标题行添加到数据网格中断了分页
- 28. 在datagridview标题下面添加textboxes行
- 29. 添加在Woocommerce产品标题换行
- 30. 在下一行添加标题属性:
@PabliSerbo - 感谢您的例子我现在明白了。但是,如何获得标题的宽度来设置线宽? – Billy 2011-05-01 06:57:34