We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Html content is overlapping header space

Hello,

I am adding headers to all pages after parsing the html to doc and it looks like the pages that automatically move to the next page are overlapping the header space.


Code example:

var loadOptions = new HtmlLoadOptions(basePath);
loadOptions.PageInfo.Width = Aspose.Pdf.PageSize.PageLetter.Width;
loadOptions.PageInfo.Height = Aspose.Pdf.PageSize.PageLetter.Height;
loadOptions.PageInfo.Margin = new Aspose.Pdf.MarginInfo(36, 36, 36, 72);
loadOptions.PageInfo.IsLandscape = false;
var streamContents = new MemoryStream(Encoding.UTF8.GetBytes(allContents));

var header = new HeaderFooter { Margin = new MarginInfo(36, 36, 36, 36) };
var img = new Image { File = _imagePath, FixHeight = 37.44, FixWidth = 37.44 };
header.Paragraphs.Add(img);
var textFrag = new TextFragment(_headerText);
textFrag.HorizontalAlignment = HorizontalAlignment.Right;
header.Paragraphs.Add(textFrag);
var line = new Line(new float[] { 0, 72, 540, 72 });
var graph = new Graph(612, 72);
graph.Shapes.Add(line);

header.Paragraphs.Add(graph);
_doc = new Document(streamContents, loadOptions);

foreach (Page page in _doc.Pages)
{
page.header = header;
}
_doc.Save(@“C:\Users\Administrator\Desktop\AsposeImplementationInlineHTML.pdf”);

What do I need to do to make sure that when content flows to another page it ends up below the header?

Thanks,
Grant

Hey Everyone,

I figured out what was happening. My header margins were causing the header to move into the page content space. I adjusted the top margin and it works as expected. I figured I would post what I did so it might help someone else out.

Thanks,
Grant

Hi Grant,


Thanks for your feedback. It is good to know you have managed to resolve the issue. Yes definitely your shared solution will help any other community member, having same issue.

Please keep using our API and feel free to ask any question or concern. We will be more than happy to extend our support.

Best Regards,