We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How can I add an image in the first page header section of a loaded docx?

I want to add an image in the header section of the first page in an already existing docx file. I am following the example syncfusion has in the "Working with Pages" section, though it is about creating a docs from scratch.I am getting the first section of the docx document, creating paragraphs, creating a byte array from an image, creating picture object from this image, and then appending the picture to the paragraph. My code is like that:

WordDocument document = new WordDocument(filePathFull);

IWSection section = document.Sections[0];

section.PageSetup.DifferentFirstPage = true;

IWParagraph paragraphQRCode = section.HeadersFooters.FirstPageHeader.AddParagraph();

paragraphQRCode.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Right;

// creating byte array from image


var picture = paragraphQRCode.AppendPicture(byteArrayImage);

picture.Width = 75;

picture.Height = 75;

document.Save("path", FormatType.DOCX);

But no image showing in the docx header? What am I missing?

1 Reply

VR Vijay Ramachandran Syncfusion Team October 4, 2017 06:53 AM UTC

Hi Deb kanti,

Thank you for contacting Syncfusion support.

You can add the picture into first page header of the existing Word document and the given code snippet is works properly (Image preserved in result document) at our end. Please find the sample from here which is used at our end to test the current scenario.

We suspect that the issue may be occur due to any particular element preserved in the input Word document. So kindly provide us following details, thereby we will analyze further and provide you a prompt solution at the earliest.

    1. Input and Output Word documents.
    2. Image used at your end.
    3. Essential Studio product version.

Please let us know if you have any questions.

Vijay R

Live Chat Icon For mobile
Up arrow icon