Graph API : Convert word document to PDF and download PDF not working for large files

AugLearn 0 Reputation points
2024-10-10T17:17:16.0633333+00:00

Hi,

I am using SharePoint Graph API to convert word document to PDF(the word document that needs to be converted is already uploaded to SharePoint). It is working for small files but failing for large files(a 50MB file failed). I referenced this link - https://learn.microsoft.com/en-us/graph/api/driveitem-get-content-format?view=graph-rest-1.0&tabs=http.

This is the call - GET /drive/root:/{path and filename}:/content?format={format}

It only works for small files. It converts word to PDF and I am able to download the PDF. When tried for large files, it throws error 406 Not Acceptable,

Response body,

"error": { "code": "notSupported", "message": "Error from Office Service. Url=https://wordcs.osi.office365.us/document/export/pdf HttpCode=UnsupportedMediaType", "innererror": { "code": "cannotOpenFile" } }

How to convert word to PDF for large files up to 1GB?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,037 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,709 questions
{count} vote

2 answers

Sort by: Most helpful
  1. Xyza Xue_MSFT 24,801 Reputation points Microsoft Vendor
    2024-10-11T02:37:24.09+00:00

    Hi @AugLearn ,

    I have the same situation in my environment as per my test. I am not sure this is an expected behavior or a bug because I didn't find any official MS article which explains this. I would suggest you directly contact Microsoft if you want to figure it out.

    Thank you for bringing things to our attention.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    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.

    0 comments No comments

  2. Hitesh Pachipulusu - MSFT 2,145 Reputation points Microsoft Vendor
    2024-10-11T06:54:29.7433333+00:00

    Hello AugLearn,

    Thank you for reaching out to Microsoft Support!

    It looks like the issue you're encountering is related to the size of the file you're trying to convert. The Microsoft Graph API has limitations when it comes to handling large files for conversion. It's an expected behavior if you are handling with large files.

    Chunked Upload and Conversion: Instead of trying to convert the entire file at once, you can try uploading the file in smaller chunks and then converting each chunk separately. This approach might help in managing the file size limitation.

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.

    0 comments No comments

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.