JavaScript:
function demoJsPdf() {
var doc = new jsPDF("landscape", "mm", "a4");
doc.setFontSize(22);
doc.text(20, 20, 'This is a exmaple of jsPDF');
doc.setFontSize(16);
doc.text(20, 30, 'This example is created by dsharma4u29.');
doc.fromHTML('<a href="javascript:window.print()">Print</a>', 20, 60, {'width': 10, 'elementHandlers': specialElementHandlers});
var iframe = document.getElementById('output');
iframe.style.width = '100%';
iframe.style.height = '400px';
iframe.src = doc.output('datauristring');
}
var specialElementHandlers = function() {
return;
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<html>
<body>
<div>
<a href="javascript:demoJsPdf()" class="button">Run Code 2</a>
<iframe id="output"></iframe>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
现在文本“Run Code 2”必须显示为超链接,但它只是显示为简单文本,而不是超链接。如何将其作为 PDF 上的超链接实现?