我是一位帮助翻译的助手。以下是您需要翻译的内容:
我正在开发一个简单的javascript程序。 我使用jsPDF库,但是脚本加载了一个空白pdf。
这是代码:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>fromHTML EX</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="generator" content="Geany 1.22" />
<script type="text/javascript" src="/root/utils/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="/root/utils/jsPDF-master1/jspdf.plugin.standard_fonts_metrics.js"></script>
<script type="text/javascript" src="/root/utils/jsPDF-master1/jspdf.plugin.split_text_to_size.js"></script>
<script type="text/javascript" src="/root/utils/jsPDF-master1/js/basic.js"></script>
<script type="text/javascript" src="/root/utils/jsPDF-master1/jspdf.js"></script>
<script type="text/javascript" src="/root/utils/jsPDF-master1/jspdf.plugin.from_html.js"></script>
<script type="text/javascript">
function PDF1(){
var doc = new jsPDF();
var elementHandler = {
'#ignorePDF': function (element, renderer) {
return true;
}
};
var source = window.document.getElementsByTagName("body")[0];
doc.fromHTML(
source,
15,
15,
{
'width': 180,'elementHandlers': elementHandler
});
doc.output("datauri");
}
PDF1()
</script>
</head>
<body>
ASDSADASDASDSA
<div>
<p id="ignorePDF">don't print this to pdf</p>
<p><font size="3" color="red">print this to pdf</font></p>
</div>
</body>
</html>
我尝试将调用函数放在页面底部,但仍然无法正常工作。有人能帮忙吗?