How can I call SharePoint to convert a DOCX/PPTX/XLSX to PDF (and HTML)?

David Thielen 3,211 Reputation points
2020-11-17T13:09:21.21+00:00

Hi all;

SharePoint has the functionality to convert an OpenXml file to PDF. (And maybe HTML?)

Is there a way to programmatically call SharePoint, from another program on a remote computer, to make this conversion? And if so, how?

Preferably a way that can work with SharePoint Online.

And if possible, with an example of exactly what code to write.

I asked this before here, but am asking again in case there is a better answer.

thanks - dave

Microsoft 365 and Office | SharePoint | For business | Windows
{count} votes

3 answers

Sort by: Most helpful
  1. Eliot Cole 6 Reputation points
    2022-06-09T14:06:19.393+00:00

    I realise that this is an old thing ... but this can now be done using the OneDrive connector's 'Convert a file (preview)' action.

    Whereby you can basically do the following:

    1. Using the content of the file in question create a PDF on your OneDrive root.
    2. Use the content of THAT file to create a new file in SharePoint.
    3. Then delete the file made on OneDrive.
    1 person found this answer helpful.
    0 comments No comments

  2. sadomovalex 3,636 Reputation points
    2020-11-17T15:44:33.72+00:00

    if mentioned standard components in the previous answers (Flow and Word automation) can't be used in your scenario you may check 3rd party apps from SPO apps catalog. E.g. this PDF converter has REST API which can be utilized:

    "Does the app have any API that I can integrate with?
    If you would like to integrate with the Muhimbi PDF Converter for SharePoint Online from your own App or code then you have the following options:

    1. Use our REST based API from C#, Java, JavaScript, PHP, Python and other languages"

  3. Allen Xu_MSFT 13,866 Reputation points
    2020-11-18T08:00:57.097+00:00

    Hi anonymous user,

    In my opinion, your requirement cannot be realized at present because SharePoint Online does not provide REST API to call Word Automation Service.

    As an alternative, I suggest you to use 3rd party tools to achieve what you want.

    I hope this information has been useful, please let me know if you still need assistance.


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


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.