Hi,
I’m trying to insert an image into the header of a word document but it doesn’t seem to work. My code is below (it’s mostly from Aspose documentation) and everything executes fine and the word doc is produced but without an image. The header text is produced though.
private Document InsertHeaderLogo(Document doc)
{
DocumentBuilder builder = new DocumentBuilder(doc);
Section currentSection = builder.CurrentSection;
PageSetup pageSetup = currentSection.PageSetup;
pageSetup.DifferentFirstPageHeaderFooter = true;
// --- Create header for the first page. ---
pageSetup.HeaderDistance = 20;
builder.MoveToHeaderFooter(HeaderFooterType.HeaderFirst);
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
// Set font properties for header text.
builder.Font.Name = "Arial";
builder.Font.Bold = true;
builder.Font.Size = 14;
// Specify header title for the first page.
builder.Write("Synergy Connect - Child Care Invoice.");
// --- Create header for pages other than first. ---
pageSetup.HeaderDistance = 20;
builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
// Insert absolutely positioned image into the top/left corner of the header.
// Distance from the top/left edges of the page is set to 10 points.
if (File.Exists(mHeaderLogoPath))
{
builder.InsertImage(mHeaderLogoPath, RelativeHorizontalPosition.Page, 10, RelativeVerticalPosition.Page, 10, 50, 50, WrapType.Through);
}
return doc;
} //InsertHeaderLogo
Any ideas?
Thanks,
Stu.