convert word document to pdf and render via office.com or web api

David McDivitt 221 Reputation points
2022-01-27T20:59:08.03+00:00

My organization uses Microsoft extensively, Sharepoint Online, Office 365, etc. I want a web application to render Word and Excel documents by converting to PDF. I read where a page at office.com can be opened, including the URL of a document, and it will be rendered. Can someone please elaborate on this functionality? The documents are blobs on an SQL Server. Ideally I would like to use HTTP post to send documents to a web address, have it render, and stay within the organization/Microsoft security environment.

Microsoft 365 and Office | Development | Other
Microsoft 365 and Office | Open Specifications
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Rob Windsor 2,001 Reputation points
    2022-01-28T23:02:42.123+00:00

    You could use the Microsoft Graph to save the document to the user's OneDrive, convert the document to PDF, and then delete the original. The API used to convert the format of a file in OneDrive is Convert Content. The response from this request includes the URL to the converted document.

    2 people found this answer helpful.
    0 comments No comments

  2. Tom Jebo 2,336 Reputation points Microsoft Employee Moderator
    2022-01-28T18:33:25.547+00:00

    Hi @David McDivitt ,

    What you are referring to may be WOPI. The WOPI protocol enables office web apps (Word, PowerPoint and Excel) to view and edit documents with in a 3rd party web app page. This is useful in situations where you can manage the documents i.e. a file server host application. It sounds like your SQL Server blob solution would fit this scenario.

    Are you planning to use the Microsoft cloud provided Office web apps? If so, in order to use a solution with the WOPI protocol, you would need to work with our Cloud Storage Partner Program, information is here:
    https://learn.microsoft.com/en-us/microsoft-365/cloud-storage-partner-program/online/

    If you are able to use an on-premises solution and can deploy Office Online Server in your enterprise, then you can implement this independently. There is information about deploying OOS here:
    https://learn.microsoft.com/en-us/officeonlineserver/office-online-server

    You can read about the WOPI protocol here:
    https://learn.microsoft.com/en-us/openspecs/office_protocols/ms-wopi/6a8bb410-68ad-47e4-9dc3-6cf29c6b046b - this is the technical specification
    https://learn.microsoft.com/en-us/microsoft-365/cloud-storage-partner-program/rest/ - this is a helpful reference for cloud integration

    There's also helpful information in the first link for both cloud and on-premises integrations, including a reference to a sample host implementation on github which I've linked here:
    https://github.com/Microsoft/Office-Online-Test-Tools-and-Documentation/tree/master/samples/SampleWopiHandler

    If you go the on-premises route, questions about the [MS-WOPI] technical specification can be direct to this Q&A forum.
    If you go the cloud route, there is a yammer group available to participants after joining.

    I hope this information helps.

    Best regards,
    Tom Jebo
    Sr Escalation Engineer
    Microsoft Open Specifications Support

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.