流星jsPDF包错误
Meteor jsPDF Package Error
我添加了js-pdf包到我的流星应用程序,但每当我运行一个简单的hello world代码,我得到一个错误:
代码:var doc = new jsPDF();
doc.setFontSize(40);
doc.text(35, 25, "Paranyan loves jsPDF");
我:
[Error] ReferenceError: Can't find variable: jsPDF
click #download-pdf (manageatas.js, line 53)
(anonymous function) (templating.js, line 120)
(anonymous function) (blaze.js, line 2205)
withCurrentView (blaze.js, line 2038)
(anonymous function) (blaze.js, line 2204)
(anonymous function) (blaze.js, line 802)
dispatch (jquery.js, line 4657)
handle (jquery.js, line 4325)
我尝试安装包,我尝试下载代码并将其添加到客户端文件夹,但我再次得到相同的错误…
我也遇到了很多问题。
试着把jspdf.debug.js在你的代码某处(我有我的客户端/第三方/),摆脱var从var jsPDF =(函数(全局),并给它一个这样的镜头。
确保先删除包和其他jspdf - js文件!
该包似乎与最近的Meteor版本不兼容(这很奇怪,因为它似乎接收更新)。我建议手动添加jspdf.js到你的/client/lib/compatibility
文件夹。
如果你不想使用compatibility
文件夹,你需要确保jsPDF
对象是在全局范围内创建的,而不是作为文件中的局部变量。幸运的是,这很容易——只需从它的声明中删除var
关键字。换句话说,第39行应该是:
jsPDF = (function () {
不是var jsPDF = (function () {
使用HTML - PDF NPM包创建动态HTML到PDF文件。
很容易使用步骤:
- 创建报告布局设计的html文件
- 通过SRS模板方法传递json格式的动态数据,获取html代码。
- 在以下函数中传递html代码
var fs = require('fs');
var pdf = require('html-pdf');
var options = { format: 'Letter' };
pdf.create(html, options).toFile('./businesscard.pdf`enter code here`', function(err, res) {
if (err) return console.log(err);
console.log(res); // { filename: '/app/businesscard.pdf' }
});
其中html代表html代码。
访问https://www.npmjs.com/package/html-pdf
相关文章:
- Node.js v6.2.0类扩展不是函数错误
- Jquery菜单操作不稳定,定位不正确,存在一般错误
- document.open/document.write没有正确地清除chrome中的文档——这是chrome的错误吗
- 试图在引导模式内动态生成图表,得到offsetWidth错误
- 为什么会出现错误;未捕获的类型错误:undefined不是函数;
- 我如何修复包含在captcha的addthis中的错误
- 同样,同样的错误'ahorcado.js:26未捕获类型错误:无法读取属性'beginPath'
- 节点是否需要模块传递带有方括号的arg?这是个错误吗
- Webpack/Rect:遵循egghead.io教程,但出现错误:您可能需要一个合适的加载程序来处理此文件类型
- CKFinder 3为所选文件返回错误的URL
- 同位素库错误:未捕获错误无布局模式包装生产线8
- 铬:“;未捕获的语法错误:意外的标记:"
- jsPDF addHTML方法不工作,没有错误消息
- 未捕获的引用错误:.jspdf未定义
- jspdf引发doc.save()错误
- 流星jsPDF包错误
- 无法使用jspdf将图像添加到pdf.返回getJpegSize错误
- 未捕获类型错误:Cannot read property 'cells'未定义的jspdf
- jspdf类型错误:this.margins未定义
- 错误:使用 jspdf 时 PNG 文件不完整或损坏