[英]Grapecity spread-sheets-pdf: savePDF() is not a function
Using NodeJs I'm trying to write a small API with Grapecity SpreadJs library.使用 NodeJs 我正在尝试使用 Grapecity SpreadJs 库编写一个小型 API。 In my project I have installed the following libraries:
在我的项目中,我安装了以下库:
When I try to call savePDF() on a Workbook instance, I have this error: savePDF() is not a function.当我尝试在 Workbook 实例上调用 savePDF() 时,出现此错误: savePDF() 不是函数。 Here my code:
这是我的代码:
GC.Spread.Sheets.LicenseKey = "myKey";
SJSExcel.LicenseKey = "myKey";
var wb = new GC.Spread.Sheets.Workbook();
var invoice = JSON.parse(fs.readFileSync("./invoice_data/invoice_example.json"));
wb.fromJSON(invoice);
wb.savePDF(function (blob) {
var fileName = 'download';
saveAs(blob, fileName + '.pdf');
},
function (error) {
console.log(error);
}
});
What's wrong?怎么了?
Thanks in advance.提前致谢。
I am a member of GrapeCity's Technical Engagement team.我是 GrapeCity 技术参与团队的成员。 I wanted to share that a NodeJS environment cannot support SpreadJS's PDF export.
我想分享一个 NodeJS 环境不支持 SpreadJS 的 PDF 导出。
The reason is that SpreadJS's PDF export feature has a deep dependency on the DOM object.原因是SpreadJS 的PDF 导出功能对DOM 对象有很深的依赖。 When exporting SpreadJS to a PDF, it is changing the graphic context from canvas to a PDF context.
将 SpreadJS 导出到 PDF 时,它会将图形上下文从画布更改为 PDF 上下文。 This requires going over all the rendering logic and requesting a lot of DOM element computing.
这需要遍历所有渲染逻辑并请求大量 DOM 元素计算。 The NodeJS environment uses a Mock jsDom that cannot provide the deep dependency that is needed and for this reason, a NodeJS environment cannot support SpreadJS exporting a PDF.
NodeJS 环境使用的 Mock jsDom 无法提供所需的深度依赖,因此,NodeJS 环境无法支持 SpreadJS 导出 PDF。
If you have any questions, feel free to reach out to the SpreadJS team here: Submit a Ticket如果您有任何问题,请随时与 SpreadJS 团队联系:提交工单
Best, Mackenzie Albitz |最佳,麦肯齐·阿尔比茨 | Technical Engagement Engineer at GrapeCity
GrapeCity 的技术参与工程师
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.