我想在我的磁盘上保存一些用"调查PDF"创建的PDF。事实上,我可以发送PDF,但我无法将其保存在磁盘上。
我的最终代码:
return surveyPDF.save(filename);
有人能帮我吗?
谢谢
你能试试吗
await surveyPDF.save(filename)
.save
似乎是下载PDF文件的异步函数。
从文档
Call save method of surveyPDF object to download file in browser. This is asynchronous method
#2如果第一种方法不起作用,你可以试试这个
function savePdfAsString() {
const surveyPDF = new SurveyPDF.SurveyPDF(json);
surveyPDF.data = survey.data;
surveyPDF
.raw("dataurlstring")
.then(function (text) {
//var file = new Blob([text], {type: "application/pdf"});
var a = document.createElement("a");
//a.href = URL.createObjectURL(file);
a.href = text;
a.download = "surveyAsString.pdf";
//document
// .body
// .appendChild(a);
a.click();
});
}
在这里,您使用.raw
函数将PDF转换为dataurlstring
,然后下载它。这是这个的文档
*未测试