Loss of Image in Header : DOCX to PDF using Sharepoint Graph API

Mani Wadhwa 1 Reputation point
2022-08-05T11:32:09.673+00:00

Hi Team,

I'm trying to convert docx file to pdf using SharePoint Graph API by calling this following GET request -

https://graph.microsoft.com/v1.0/sites/894f9bf8-01d7-471e-82ac-7354e4c21200/drive/root:/File_Conversion_Test/Header_Banner_Loss_Document.docx:/content?format=pdf

In the converted PDF file, there is a loss of Image which was present in the header.

I tried using OneDrive Connector in Power Automate as well to convert the docx to pdf but it has the same issue - Loss of Image in Header.

Is there any limitations on any kind of images in the docx file that are not convertible to PDF in SharePoint API.

Original DOCX file has following header -

228520-image.png

When converted to PDF using SharePoint graph api, image no longer exists -

228525-image.png

I can share the docx file as well if required.

Viva Connections
Viva Connections
A Microsoft Viva module that provides a gateway to a modern engagement experience.
100 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,238 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,797 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,030 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 36,091 Reputation points Microsoft Vendor
    2022-08-08T07:39:18.05+00:00

    Hi @Mani Wadhwa ,
    Per my test, I can convert the docx file with a header to pdf successfully.
    228959-image.png
    After doing some research, there are following reasons might cause images disappear after converting the document to docx or PDF:

    1. Image size: If the inserted image size is larger than 10 MB, then it will not get printed during PDF export.
    2. Authenticated images: Images inserted directly from other sources into a document may require some additional authentication to access and process the image during PDF conversion. Such images will not be shown while converting the document to PDF. To insert authenticated images, you can download these images locally into a folder in your computer, and then insert the same in your Writer document.
    3. If a document contains base64 or WMF images, then such images will not get exported [due to limitations] while converting the document to docx, rtf or pdf. To avoid this issue, please use image formats like JPEG , JPG or PNG to yield better results.
    4. Floating images will not be shown while converting the document into PDF, since the image is too wide to fit the page size. To avoid this issue, try resizing the image dimensions and try again.

    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.



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.