【问题标题】:How to create PDF with anchor tag using DOMPDF如何使用 DOMPDF 创建带有锚标记的 PDF
【发布时间】:2014-11-23 12:09:28
【问题描述】:

我正在尝试在使用 DOM PDF 库创建的 pdf 中包含锚标记。下面是代码

$html = ob_get_clean();     
$html = '<!DOCTYPE html><html><head><style> *{margin:0;padding:0} </style></head>
<body style="font-family: Helvetica; background:#fff; width:692pt; height:712pt;">';
$html .= '<a href="http://www.google.com" target="_blank">Click for Google</a>';
$html .= '</body></html>';

$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->set_paper('letter', 'landscape');
$dompdf->render();

链接显示在生成的 pdf 中。但是当我点击它时,什么也没有发生。我想在浏览器中打开链接。有什么建议吗?

【问题讨论】:

标签: php dom pdf-generation anchor dompdf


【解决方案1】:

它对我有用:

<script type="text/php">
$html = ob_get_clean();     
$html = '<!DOCTYPE html><html><head><style> *{margin:0;padding:0} </style></head>
<body style="font-family: Helvetica; background:#fff; width:692pt; height:712pt;">';
$html .= '<a href="http://www.google.com" target="_blank">Click for Google</a>';
$html .= '</body></html>';

$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->set_paper('letter', 'landscape');
$dompdf->render();

</script>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-07-11
    • 2023-03-22
    • 1970-01-01
    • 2015-05-18
    • 1970-01-01
    • 2011-12-14
    • 1970-01-01
    • 2012-02-01
    相关资源
    最近更新 更多