简体   繁体   English

DomPdf中的单选按钮呈现

[英]Radio button rendering in DomPdf

I'm creating a Pdf from html using DomPdf and the following radio button renders in the Pdf when created on my local server (XAMP on Win7): 我正在使用DomPdf从html创建一个Pdf,并且在本地服务器(Win7上的XAMP)上创建时,以下单选按钮在Pdf中呈现:

<input type="radio" name="test" value="1" checked />

But when rendered using the online server it produces a question mark, rather than a radio button. 但是,当使用在线服务器进行渲染时,它会产生一个问号,而不是单选按钮。 The html is exactly the same and the DomPdf class files are exactly the same. html完全相同,DomPdf类文件完全相同。 The other html elements are fine. 其他html元素也很好。 Also tried without 'checked' and without the closing tag. 也尝试了没有'checked'和没有结束标签的情况。 Any ideas please? 有什么想法吗?

As requested here is the full code of a simplified test page, with one radio button (it makes no difference having multiple radios). 这里要求的是一个简化的测试页的完整代码,带有一个单选按钮(具有多个单选按钮没有区别)。

<?php
ob_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
</head>
<body>
<input type="radio" name="test" value="1" checked />
</body>
</html>

<?php
$html = ob_get_clean();

use Dompdf\Adapter\CPDF;
use Dompdf\Dompdf;
use Dompdf\Exception;

require_once("dompdf/autoload.inc.php");

$dompdf = new Dompdf();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("radio.pdf", array('Attachment'=>'0'));
?>

Because you've set a different value for name attribute, they should have a common name value, just like you group items, for example: 因为您为name属性设置了其他值,所以它们应该具有相同的名称值,就像您对项目进行分组一样,例如:

  <input type="radio" name="group1" /> <input type="radio" name="group1" /> <input type="radio" name="group1" /> <!-- You can select any one from each group --> <input type="radio" name="group2" /> <input type="radio" name="group2" /> <input type="radio" name="group2" /> 

It was the font cache lib/fonts/dompdf_font_family_cache.php. 这是字体缓存lib / fonts / dompdf_font_family_cache.php。 I had uploaded the copy from my local server. 我已经从本地服务器上传了副本。 Once I uploaded the 'dist' copy the radios and checkbox rendered correctly. 上传“ dist”后,请复制广播和复选框,以使其正确呈现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM