Table of Contents

Example: Object Alignment

The example creates a simple report with a header, footer and content.

Result

Result of MyFirstReport

Remarks

The class MyFirstReport defines a custom report inheriting from HeaderFooterReport.

Constructor

The code in the constructor is setting up a specific header with a company name, report title and subtitle. It also sets the margin of the content, i.e. the distance between the header and the content.

Create

The Create method overrides the base Create method to add specific report content. It creates the content of the report, including header (CreateHeader), custom text and footer (CreateFooters).

Code

using Root.ReportNet.Pdf;
using System;

namespace Root.ReportExamples.HeaderFooterExamples;

public sealed class MyFirstReport : HeaderFooterReport {
  public MyFirstReport() {
    CompanyName.Text = "My Company";
    Title.Text = "My First Report";
    Subtitle.Text = "Example of a simple report";

    ContentMarginTopMM = 20;
  }


  protected override void Create() {
    RepString rs = new(TextFont, "Here is some content.");
    AddContent(rs);

    rs = new(TextFont, "This text is positioned with absolute values.");
    CurPage.AddMM(MarginLeftMM + 40, 150, rs);
  }
}