How to set the HeaderElement to specific page

Hello,

We’re trying to generate a banner using canvas and trying to set the HeaderElement over the banner but somehow HeaderElement is rendering in new page. Can you please suggest how we can set the HeaderElement in specific page? Please check the below code snippet and attached files.

Aspose.Pdf.Document doc = new Aspose.Pdf.Document();
ITaggedContent taggedContent = doc.TaggedContent;
taggedContent.SetTitle(“Tagged test accessibility document by synoptek”);
taggedContent.SetLanguage(“en-US”);
HeaderElement h1 = taggedContent.CreateHeaderElement(1);
FileStream fontStreamForH1 = System.IO.File.OpenRead(“wwwroot//Fonts//lato//Lato-Black.TTF”);
h1.StructureTextState.Font = FontRepository.OpenFont(fontStreamForH1, FontTypes.TTF);
h1.SetText(“Harness Emerging Technologies To Guide Business Strategy”);
h1.StructureTextState.ForegroundColor = Aspose.Pdf.Color.Black;
h1.StructureTextState.MarginInfo = new MarginInfo { Left = 90, Bottom = 0, Right = 30, Top = 10 };
rootElement.AppendChild(h1);

var canvas = new Aspose.Pdf.Drawing.Graph((float)doc.PageInfo.Width, (float)doc.PageInfo.Height);
doc.Pages.Add();
doc.Pages[1].Paragraphs.Add(canvas);
doc.PageInfo.Margin = new MarginInfo(0, 0, 0, -5);
float h = 260;
float b = 595;
Aspose.Pdf.Drawing.Rectangle myRec = new Aspose.Pdf.Drawing.Rectangle(0, b, 1000, h);
var c = ColorTranslator.FromHtml("#273e85");
myRec.GraphInfo.Color = Aspose.Pdf.Color.FromRgb©;
var cd = ColorTranslator.FromHtml("#273e85");
myRec.GraphInfo.FillColor = Aspose.Pdf.Color.FromRgb(cd);

canvas.Shapes.Add(myRec);

doc.Save(“wwwroot//PDFs//” + fileName, SaveFormat.Pdf);

Regards,result.pdf (25.8 KB)
expectation.jpg (25.1 KB)

@siriussynoptek

We have logged an investigation ticket as PDFNET-49592 in our issue tracking system for you requirements after testing the scenario with Aspose.PDF for .NET 21.2. We will further check the feasibility of your required feature and let you know as soon as the logged ticket is resolved. Please be patient and spare us some time.

We are sorry for the inconvenience.