jsPDF fromHTML()未显示图片 [英] jsPDF fromHTML() not show image
本文介绍了jsPDF fromHTML()未显示图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
HTML代码:
<div id="customers" >
<div class="">
<div class="heading">
<img class="form_head" src="http://dev.syntrio.in/kchr-project/images/kchr-kchr.png" alt="">
</div>
<button onclick="javascript:demoFromHTML();">PDF</button>
JS代码:
function demoFromHTML() {
var pdf = new jsPDF('p', 'pt', 'letter');
// source can be HTML-formatted string, or a reference
// to an actual DOM element from which the text will be scraped.
source = $('#customers')[0];
// we support special element handlers. Register them with jQuery-style
// ID selector for either ID or node name. ("#iAmID", "div", "span" etc.)
// There is no support for any other type of selectors
// (class, of compound) at this time.
specialElementHandlers = {
// element with id of "bypass" - jQuery style selector
'#bypassme': function (element, renderer) {
// true = "handled elsewhere, bypass text extraction"
return true
}
};
margins = {
top: 80,
bottom: 60,
left: 40,
width: 10000
};
// all coords and widths are in jsPDF instance's declared units
// 'inches' in this case
pdf.fromHTML(
source, // HTML string or DOM elem ref.
margins.left, // x coord
margins.top, { // y coord
'width': margins.width, // max width of content on PDF
'elementHandlers': specialElementHandlers
},
function (dispose) {
// dispose: object with X, Y of the last line add to the PDF
// this allow the insertion of new lines after html
pdf.save('Test.pdf');
}, margins);
}
我包括jspdf.debug.js.当我单击pdf按钮时,生成了pdf,但未显示html代码中的图像.我得到了一个空白的pdf文件.请帮助我解决此问题
I am included jspdf.debug.js. When I click the pdf button, pdf was generated, but the image in the html code is not displayed. I got a blank pdf. Please help me to fix this problem
推荐答案
我遇到了同样的问题,但是由于我在chrome中进行了尝试,firefox对其进行了尝试,并且仍然有效,因此看不到我的图像,表明该代码是美好的.我要澄清的是,我对这个主题了解不多,但是如果您想在任何浏览器中运行,都可以使用Web服务器.
I had the same problem, but my image is not seen because i tried it in chrome , firefox tried it on and if it worked , indicating that the code is fine. I clarify that I do not know much this topic , but if you want to operate in any browser you can use a web server.
这篇关于jsPDF fromHTML()未显示图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文