Free Support Forum - aspose.com

Issue with inserting a heading above the table

Yes, that fixed it. Thank you. I have a different question about the excel to pdf conversion.
After converting excel to pdf, I need to insert a heading, but as you can see it on the attached image, it runs into the table: image.png (31.6 KB)
Here is my insertion code:

Aspose.Pdf.Document doc4 = new Aspose.Pdf.Document(outputPath);
var pg = doc4.Pages[1];
Heading title = new Heading(1);
title.Text = “Equipment Schedules”;
title.HorizontalAlignment = HorizontalAlignment.Center;
title.TextState.FontSize = 30;
title.Margin = new MarginInfo(0, 30, 0, 0);
pg.Paragraphs.Insert(0, title);
doc4.Save(outputPath);
doc4.Dispose();

As you can see, I am trying to set a bottom margin, but that doesn’t seem to help.
Examining pg variable in debugger, it does not have any paragraphs except for title, but a lot of things in the Contents collection.
Thank you

@mpogorelov

Thank you for contacting support.

Would you please share source PDF document so that we may try to reproduce and investigate it in our environment. Before sharing requested data, please ensure using Aspose.PDF for .NET 19.11.

yes, source pdf attacheddoc4.pdf (51.0 KB)
I tried 19.11 version and same issue is happening.

@mpogorelov

Thank you for sharing requested data.

Please note that existing content in source PDF document is present as plain text on the page. Existing contents can be moved in DOCX files but not in PDF files. Neither the API knows boundaries of existing paragraphs, images etc so such overlaps can occur. You would need to manually adjust position or size of text to avoid this problem.