Allows user to build document content in event handler.

Namespace:  C1.C1Preview
Assembly:  C1.C1Report.2 (in C1.C1Report.2.dll)

Syntax

C#
public event EventHandler GenerateDocument
Visual Basic
Public Event GenerateDocument As EventHandler

Examples

The following example creates a GenerateDocument event to enable the Reflow button in the preview:

Copy CodeVisual Basic
Private _sampleText As String = "This is an example"
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
    generateC1PrintDocument(C1PrintDocument1)
End Sub
Private Sub generateC1PrintDocument(ByVal doc As C1.C1Preview.C1PrintDocument)
    ' Render the document.
    doc.StartDoc()
    Dim theader As C1.C1Preview.RenderTable = New C1.C1Preview.RenderTable(Me.C1PrintDocument1)
    ' Set up alignment for the columns of the header.
    theader.Cells(0, 0).Style.TextAlignHorz = C1.C1Preview.AlignHorzEnum.Left
    theader.Cells(0, 1).Style.TextAlignHorz = C1.C1Preview.AlignHorzEnum.Center
    theader.Cells(0, 2).Style.TextAlignHorz = C1.C1Preview.AlignHorzEnum.Right
    theader.CellStyle.Font = New Font("Arial", 14)
    theader.Cells(0, 0).Text = "Left part"
    theader.Cells(0, 1).Text = "Center part"
    theader.Cells(0, 2).Text = "Right part"
    doc.RenderBlock(theader)
    ' First render some block flow text.
    doc.RenderBlockText(_sampleText)
    ' Now render direct text at an arbitrary position on the page.
    doc.RenderDirectText("3cm", "4cm", "This is direct text. It can wrap inside the specified width.", "60%", New Font("Arial", 20), Color.Red, C1.C1Preview.AlignHorzEnum.Left)
    doc.EndDoc()
End Sub
' Providing a GenerateDocument handler will enable reflow button in the preview.
Private Sub C1PrintDocument1_GenerateDocument(ByVal sender As Object, ByVal e As EventArgs)
    generateC1PrintDocument(C1PrintDocument1)
End Sub
Copy CodeC#
private string _sampleText = "This is an example";
private void Form1_Load(object sender, EventArgs e)
{
    generateC1PrintDocument(c1PrintDocument1);
}
private void generateC1PrintDocument(C1.C1Preview.C1PrintDocument doc)
{
    // Render the document.
    doc.StartDoc();
    C1.C1Preview.RenderTable theader = new C1.C1Preview.RenderTable(this.c1PrintDocument1);
    // Set up alignment for the columns of the header.
    theader.Cells[0, 0].Style.TextAlignHorz = C1.C1Preview.AlignHorzEnum.Left;
    theader.Cells[0, 1].Style.TextAlignHorz = C1.C1Preview.AlignHorzEnum.Center;
    theader.Cells[0, 2].Style.TextAlignHorz = C1.C1Preview.AlignHorzEnum.Right;
    theader.CellStyle.Font = new Font("Arial", 14);
    theader.Cells[0, 0].Text = "Left part";
    theader.Cells[0, 1].Text = "Center part";
    theader.Cells[0, 2].Text = "Right part";
    doc.RenderBlock(theader);
    // First render some block flow text.
    doc.RenderBlockText(_sampleText);
    // Now render direct text at an arbitrary position on the page.
    doc.RenderDirectText("3cm", "4cm", "This is direct text. It can wrap inside the specified width.", "60%", new Font("Arial", 20), Color.Red, C1.C1Preview.AlignHorzEnum.Left);
    doc.EndDoc();
}
// Providing a GenerateDocument handler will enable reflow button in the preview.
private void c1PrintDocument1_GenerateDocument(object sender, EventArgs e)
{
    generateC1PrintDocument(c1PrintDocument1);
}

See Also