I am upgrading to the latest version of PDF using the .NET library. I have a heading for the page that is 11 lines and it prints correctly, but when I add additional lines to the report using the following code, the lines overwrite the heading. My questions are:
a) How to get the text to start below the heading automatically?
b) Will the page overflow to a new page automatically as before?
In the previous version I was using the following code for the header and lines of the report (section was created as Section):
private void SetHeader(List<PDFTextLine> headerLines)
{
if(headerLines != null && headerLines.Count > 0)
{
Aspose.Pdf.Generator.HeaderFooter header = new Aspose.Pdf.Generator.HeaderFooter(section);
foreach(PDFTextLine pdfTextLine in headerLines)
{
string lineToUse = pdfTextLine.Line;
if (String.IsNullOrEmpty(pdfTextLine.Line))
lineToUse = "#$NL";
Text text = new Text(lineToUse);
text.TextInfo.FontName = pdfTextLine.FontDefinition.FontName;
text.TextInfo.FontSize = pdfTextLine.FontDefinition.Size;
header.Paragraphs.Add(text);
}
section.OddHeader = header;
section.EvenHeader = header;
}
}
public void AddLine(string line)
{
if(section != null)
{
Text text = new Text(line);
section.Paragraphs.Add(text);
}
}
In the current version I am using:
private void SetHeader(List<PDFTextLine> headerLines)
{
if(headerLines != null && headerLines.Count > 0)
{
Aspose.Pdf.HeaderFooter header = new Aspose.Pdf.HeaderFooter();
header.Margin = page.PageInfo.Margin;
foreach(PDFTextLine pdfTextLine in headerLines)
{
string lineToUse = pdfTextLine.Line;
if (String.IsNullOrEmpty(pdfTextLine.Line))
lineToUse = "\n";
TextFragment text = new TextFragment(lineToUse);
text.TextState.Font = FontRepository.FindFont(pdfTextLine.FontDefinition.FontName);
text.TextState.FontSize = pdfTextLine.FontDefinition.Size;
header.Paragraphs.Add(text);
}
page.Header = header;
}
public void AddLine(string line)
{
if(page != null)
{
TextFragment text = new TextFragment(line);
page.Paragraphs.Add(text);
}
}
If you have references that give a good description of how to use these effectively that would be helpful. Thank you for any pointers.
Jeff