Welcome Guest Search | Active Topics | Sign In | Register

Overlay an HTML element in the empty space of the page header Options
JS
Posted: Tuesday, June 25, 2024 10:20:40 AM
Rank: Newbie
Groups: Member

Joined: 6/25/2024
Posts: 1
I'm trying to overlay a banner in the header region of each page.

This is the code I'm currently using and it produces the result shown in the image. Please assist me in being able to better position the banner. I couldn't insert the screenshot. I can send an email if having a visual helps.

Code: C#
MemoryStream stream = new(fileBytes);
            PdfDocument document = new PdfDocument(stream);
            PdfPage page = document.Pages[0];

            HtmlToPdfOptions options = new()
            {
                HeaderHtmls = new string[] { $@"<div id=""aur-watermark"" style=""border: 3px solid black; padding: 4px; width: max-content; font-size: 10px"">
                                        <strong>Aurelia Dormamu Information</strong><br>
                                        Controlled by: <span id=""aur-controller"">XXXXXX</span>
                                        </div>" },
                //HeaderHtmlPosition = 20.5f
            };

            EO.Pdf.HtmlToPdf.Options.OutputArea = new RectangleF(406f, 785f, 8.5f, 11f);

            var result = EO.Pdf.HtmlToPdf.ConvertHtml($@"", page, options);

eo_support
Posted: Tuesday, June 25, 2024 11:18:41 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

The header position is determined as follow:

Left: OutputArea.Left. In your case it would 406f;
Top: HeaderHtmlPosition;

As a test, you can set both as 0 and then the header will start immediately from the top left corner of the page. You can then adjust your HeaderHtml to position the actual content. For example, if you want to move the header html to the right, add a padding left to your HTML.

Also why do you have such large Left/Top value for your OutputArea?

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.