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

AugLearn 5 Reputation points
Oct 10, 2024, 5:17 PM

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://video2.skills-academy.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,716 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,170 questions
{count} vote

3 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. Hitesh Pachipulusu - MSFT 3,545 Reputation points Microsoft Vendor
    Oct 11, 2024, 6:54 AM

    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.


  3. Xyza Xue_MSFT 27,036 Reputation points Microsoft Vendor
    Oct 18, 2024, 2:09 AM

    Hi @AugLearn ,

    I'm glad to hear you solve the problem, if you have any issue about SharePoint, you are welcome to raise a ticket in this forum.

    I would make a brief summary of this thread:

    Issue Symptom:

    Graph API : Convert word document to PDF and download PDF not working for large files(a 50MB file failed).

    Current status:

    Seems to be resolved now but couldn't find any reports in any of the status dashboards.


    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.


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.