php - 由 DOMPDF 转为 PDF 的 HTML 表格
问题描述
我有一个数据库表包含一些信息,我正在检索 html 表中的表信息,我正在尝试将此表导出为 pdf 文件,我得到了???由于未知原因,在某些数字上,我使用的是 Xampp,PHP 版本 5.4。DomPdf 0.6 我将在下面分享我的代码:
<?php
$contentinvoice=
'<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<style> body { font-family: Helvetica; font-size:10px; } </style>
</head>
<body>
<table width="100%">
<tr>
<td>Code</td>
<td>Description</td>
<td>Quantity</td>
<td>Price</td>
</tr>';
$select="SELECT * FROM invoicelines";
$run=mysql_query($select,$con);
if(!$run)die("Error".mysql_error());
for($counter=1;$row=mysql_fetch_assoc($run);$counter++){
$contentinvoice.=
'<tr>
<td align="center">'.$row['code'].'</td>
<td align="center">'.$row['description'].'</td>
<td align="center">'.$row['quantity'].'</td>
<td align="center">'.$row['price'].'</td>
</tr>';
}
$contentinvoice.='</table></body></html>';
require_once("dompdf/dompdf_config.inc.php");
$dompdf = new Dompdf();
$dompdf->load_html(ob_get_clean());
$dompdf->load_html($contentinvoice, 'UTF-8');
$dompdf->set_paper('A4');
$dompdf->render();
$dompdf->stream("dompdf_out.pdf", array("Attachment" => false));
?>
我得到的结果与我需要的相同,但有些数字被替换为??? 喜欢
Code Description Quantity Price
124?1231 Item 1 ? ?.189
412?3123? Item 2 ? ?.234
注意:如果我在标题中将字体更改为 DejaVu Sans 符号?将转换为阿拉伯数字,例如 ?.189 将是١.189
解决方案
推荐阅读
- numpy-ndarray - 从 numpy 数组创建橙色表
- python - os.path.islink 在使用 Python 3.8 的 Windows 10 上不断返回 False
- mysql - mysql服务器的空闲负载 - 如何停止它
- javascript - 页面在提交按钮上不断重新加载
- powershell - PowerShell 5.1 不工作,不允许运行任何脚本/Cmdlet
- python - 如何在字节字符串中调用变量
- r - 快速放大闪亮会使人失去控制
- windows - 使用 for 循环删除几个模式后如何从命令输出中提取动态模式
- php - 如何在 URL 中传递韩文字符
- python - Python 类型提示:`def f(e: Union[np, tf])` for `import numpy as np`?