【发布时间】:2020-04-14 13:07:42
【问题描述】:
是否可以在 Word 网络应用程序中以编程方式导出/打印为 pdf?
我的研究表明这目前是不可能的,但我想确保我不会错过任何东西
【问题讨论】:
标签: office365 office-js word-addins
是否可以在 Word 网络应用程序中以编程方式导出/打印为 pdf?
我的研究表明这目前是不可能的,但我想确保我不会错过任何东西
【问题讨论】:
标签: office365 office-js word-addins
是的,你可以试试这个getFileAsync API:
【讨论】:
这里是获取 PDF 格式文档的示例代码。
// The following example gets the document in PDF format.
Office.context.document.getFileAsync(Office.FileType.Pdf,
function(result) {
if (result.status == "succeeded") {
var myFile = result.value;
var sliceCount = myFile.sliceCount;
app.showNotification("File size:" + myFile.size + " #Slices: " + sliceCount);
// Now, you can call getSliceAsync to download the files,
// as described in the previous code segment (compressed format).
myFile.closeAsync();
}
else {
app.showNotification("Error:", result.error.message);
}
}
【讨论】: