【问题标题】:programmatically export/print to pdf以编程方式导出/打印为 pdf
【发布时间】:2020-04-14 13:07:42
【问题描述】:

是否可以在 Word 网络应用程序中以编程方式导出/打印为 pdf?

我的研究表明这目前是不可能的,但我想确保我不会错过任何东西

【问题讨论】:

    标签: office365 office-js word-addins


    【解决方案1】:

    是的,你可以试试这个getFileAsync API:

    【讨论】:

      【解决方案2】:

      这里是获取 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);
              }
      }
      

      【讨论】:

      • 感谢您提供示例代码。这对于理解其他答案中的链接非常有帮助。但另一篇文章中的链接也很重要。不幸的是,我无法将 2 个帖子标记为答案。
      猜你喜欢
      • 2010-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-24
      • 2012-12-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多