Hii Team,
I am trying to add a image to the document header by using the image ID. But my method is not working. could you please help me to complete it?
private static void AddHeader(Document document, System.Func<DependentContent, Task<ContentsDto>> GetDependency)
{
var dependentContent = new DependentContent()
{
Id = "fa197b43-5b2a-4c53-bddd-3dad534f0284",
};
var content = GetDependency(dependentContent).Result;
if (content.Found)
{
DocumentBuilder builder = new DocumentBuilder(document);
Section currentSection = builder.CurrentSection;
PageSetup pageSetup = currentSection.PageSetup;
pageSetup.HeaderDistance = 20;
builder.MoveToHeaderFooter(HeaderFooterType.HeaderFirst);
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
//Initialize a Header Instance
using (var inputStream = new MemoryStream(content.Data))
{
var inputImageFromStream = Image.FromStream(inputStream);
Shape shape = builder.InsertImage(inputImageFromStream);
shape.VerticalAlignment = VerticalAlignment.Center;
}
}
}