用jsPDF从Iframe内容下载PDF文件
download PDF file from an Iframe content with jsPDF
我想保存一个包含IFrame内容的PDF文件。我使用jsPDF 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 = $('#iframeid')[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
'#emptyid': 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');
}
当我尝试这个我变成这个错误在Chrome:
Uncaught TypeError: Cannot read property 'widths' of undefined
可能是什么问题?
添加jspdf.plugin.standard_fonts_metrics.js
.
相关文章:
- 如何使用javascript或html下载PDF格式的填写表单
- 在提交时打开thankyou.html+下载PDF
- 如何在网络上下载pdf
- 如何使用HtmlUnit下载PDF文件
- 如何创建和下载PDF和docx格式的文件,该文件将从AngularJS中的表中的数据创建
- 下载pdf格式不正确
- 下载pdf/word按钮javascript /jquery
- 提供下载pdf或在浏览器中打开的选项
- 使用 JavaScript 下载 PDF 文件
- PHP/HTML:下载PDF链接处理页面加载
- 从 AngularJS 中的 .NET 控制器下载 PDF
- 提交表单时自动“下载”PDF
- 无法使用 Angular.js 下载 pdf 文件
- 如何在不打开浏览器的情况下下载pdf文件
- 如何使用来自服务的响应下载 pdf
- 使用 jquery 下载 PDF
- 使用 php 下载 PDF,不在资源管理器和 safari 中工作
- 浏览器请求文件,服务器下载 pdf,浏览器在 iframe 中显示 pdf
- 使用jQuery下载PDF(不打开)
- 如何使用js自动下载PDF