- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在生成带有 SVG 内容的 pdf 保持设计时遇到问题。 SVG 链接在 html 内部,并使用 html 生成 pdf。但不能正常工作。
这是代码:
$dompdf = new DOMPDF();
//HTML Content
$html = <<<EOD
<html>
<head>
<style type="text/css">
html {
margin: 1%;
padding: 0;
}
.header,
.footer {
width: 100%;
text-align: center;
position: fixed;
font-size: 26px;
}
.header {
top: 0px;
}
.footer {
bottom: 18px;
}
.center {
margin: 0 auto;
}
.divTable{
display: table;
width: 100px;
text-align: center;
margin: 0 auto;
}
.divTableRow {
display: table-row;
}
.divTableHeading {
margin: 0 auto;
}
.divTableCell, .divTableHead {
display: table-cell;
padding: 0 33px;
}
.bottom .divTableCell {
padding-top: 30px;
}
.divTableHeading {
display: table-header-group;
font-weight: bold;
}
.divTableFoot {
display: table-footer-group;
font-weight: bold;
}
.divTableBody {
display: table-row-group;
}
div.img-border img {
border: 2px solid #eb0089;
}
</style>
</head>
<body>
<div class="center">
<div class="divTable top">
<div class="divTableBody">
<div class="divTableRow">
<div class="divTableCell" style="padding-left:0px;"><div class="img-border"><img src="$small_image"></div></div>
<div class="divTableCell"><div class="img-border"><img src="$small_image"></div></div>
<div class="divTableCell" style="padding-right:0px;"><div class="img-border"><img src="$small_image"></div></div>
</div>
</div>
</div>
<div class="divTable bottom">
<div class="divTableBody">
<div class="divTableRow">
<div class="divTableCell" style="padding-left:0px;"><div class="img-border"><img src="$large_image"></div></div>
<div class="divTableCell" style="padding-right:0px;"><div class="img-border"><img src="$large_image"></div></div>
</div>
</div>
</div>
</div>
<div class="footer">
$customer_title - $customer_order_number
</div>
</body>
</html>
EOD;
//PDF Options
$dompdf->set_option( 'dpi' , '300' );
$dompdf->load_html($html);
$dompdf->setPaper('A4', 'portrait');
$dompdf->set_option( 'isRemoteEnabled', true );
$dompdf->render();
$output = $dompdf->output();
file_put_contents('path-to-pdf/new.pdf);
最佳答案
我一直在寻找,直到我终于想出了自己的解决方案。我想我应该分享一下,以防对其他人有用。如果您正在使用 PHP 内联 SVG 图像(对我而言)的最佳解决方案是使用 输出它BASE64_ENCODE() 在实际的 svg 上,然后使用 src 将其包装在图像中,如下所示:
$svg = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 36 36" class="circular-chart">
<path class="circle-bg"
stroke-width="1"
fill="none"
stroke="#ddd"
d="M18 2.0845
a 15.9155 15.9155 0 0 1 0 31.831
a 15.9155 15.9155 0 0 1 0 -31.831"
/>
</svg>';
$html = '<img src="data:image/svg+xml;base64,'.base64_encode($svg).'" width="100" height="100" />';
关于php - Dompdf 无法从 SVG 正确生成 pdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48844649/
我正在尝试使用 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
我是一名优秀的程序员,十分优秀!