我想保存一个包含IFrame内容的PDF文件,我正在使用jsPDF进行操作。当我点击调用该函数的按钮时,脚本会创建一个空的PDF页面。
框架的内容如下:https://jsfiddle.net/ss6780qn/ 我正在使用以下脚本:
框架的内容如下:https://jsfiddle.net/ss6780qn/ 我正在使用以下脚本:
<script src="../jspdf/plugins/standard_fonts_metrics.js"></script>
<script type="text/javascript">
function toPDF(){
var pdf = new jsPDF('p', 'in', 'letter');
// source can be HTML-formatted string, or a reference
// to an actual DOM element from which the text will be scraped.
source = $('#frame')[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
'div': function(element, renderer){
// true = "handled elsewhere, bypass text extraction"
return true
}
}
// all coords and widths are in jsPDF instance's declared units
// 'inches' in this case
pdf.fromHTML(
source // HTML string or DOM elem ref.
, 0.5 // x coord
, 0.5 // y coord
, {
'width':7.5 // max width of content on PDF
,'elementHandlers': specialElementHandlers
}
)
pdf.save('Test.pdf');
}
有人知道出了什么问题,我该如何解决吗?