Reputation: 516
I am starting the "Build your first Word task pane add-in" tutorial.
Basically I want to make a Button on the Panel that will send this document as a PDF to my web service.
There is a function in the API called Office.Document.getFileAsync which seem to be an excellent way to save data to a PDF, which I can then send to my web service.
How do I access that part of the API. In the tutorial it seem that we should use the context object, but context.document.getFileAsync does not appear to exist. I think I need to get to the Office.Document object and I think context.document is Word.RequestContext.document.
export async function run() {
return Word.run(async (context) => {
/**
* Insert your Word code here
*/
{{Office.Document then use getFileAsync }}
await context.sync();
});
}
Upvotes: 1
Views: 794
Reputation: 9684
There are two different branches to the Office JavaScript library. There are the Common APIs which apply, theoretically, to any Office application. There are also the application-specific APIs that apply to just one Office application. There are application-specific APIs for Word, Excel, and PowerPoint, among others. The Word tutorial uses the Word application-specific APIs because that is the set of APIs that is most often used. However, for what you want to do, you should use the Common APIs. Specifically, the one that you discovered, Office.document.getFileAsync
.
You can find code samples that use Office.document.getFileAsync
in Get the whole document from an add-in in Word. Also, checkout Office JavaScript API object model.
Upvotes: 1