Graph API - DOC TO PDF CONVRESION | CONTENT SHIFT/DISTORTED IN PDF CONVERSION

Vaibhav Singh 0 Reputation points
2023-09-06T10:24:29.2466667+00:00

Hi Team,

I am using the graph API for converting docx and doc files to pdf files.

API - https://graph.microsoft.com/v1.0/drives/:driveid/items/:itemid/content?format=pdf

Getting below issues -

  1. The generated PDF file is having content shift or content distortion issues.
  2. The page count is different between the original docx file and the generated pdf file via the graph API for a few documents.
  3. The content view of the original docx file is different from the generated pdf file for a few documents.

Thanks & Regards

Vaibhav Singh

Microsoft 365 and Office | SharePoint | Development
Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. msft-gu 1,360 Reputation points
    2023-09-06T13:13:49.0833333+00:00

    Hello Vaibhav,

    Good day and thank you for your question. I reproduced this on our end using the supported formats, but I didn't encounter any issues.

    I also checked same issues on Q&A and found the following that might be helpful to you:

    https://learn.microsoft.com/en-us/answers/questions/959474/mismatch-in-page-count-docx-to-pdf-using-sharepoin

    https://learn.microsoft.com/en-us/answers/questions/956714/loss-of-image-in-header-docx-to-pdf-using-sharepoi


  2. 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.

    1 deleted comment

    Comments have been turned off. Learn more

  3. Vaibhav Singh 0 Reputation points
    2023-09-06T13:36:14.7033333+00:00

    Hi Team, Please find below the document for which I can see this issue.

    Original Docx Screenshot [As unable to upload docx in this comment]-

    Errored Pdf - error.pdf

    Let me know, if you need any additional information.

    0 comments No comments

  4. Anonymous
    2023-09-07T07:26:40.5066667+00:00

    HI @Vaibhav Singh

    Thanks for letting us know your user experience. According to your case description, I do understand how frustrated you are now.

    According to my investigation, the format that affects the generated pdf should depend on the format in the original file.

    This could be due to one of the following reasons:

    1. The content in your table exceeds the width of the PDF page, causing the table to be split into multiple rows or columns, taking up more space.
    2. The content in your table contains newline characters or other special characters, which causes the row height or column width of the table to be inconsistent and takes up more space.
    3. The content in your table uses different fonts or font sizes, resulting in inconsistent format of the table and taking up more space.

    To fix this, you can try the following:

    1. Adjust the content in your table to fit the width of the PDF page without splitting or zooming.
    2. Remove or replace newlines or other special characters in the content of your table to keep it consistent and concise.
    3. Unify the font and font size of the content in your tables to keep them consistent and clear.

    It is recommended that you adjust the content space of the original document first and compress the space before converting. By repeatedly debugging the content of the original file and outputting it to a format you are satisfied with.


    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.

    Best Regards

    Cheng Feng


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.