Allows user to build document content in event handler.
Namespace:
C1.C1Preview
Assembly:
C1.C1Report.2 (in C1.C1Report.2.dll)
Syntax
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)
doc.StartDoc()
Dim theader As C1.C1Preview.RenderTable = New C1.C1Preview.RenderTable(Me.C1PrintDocument1)
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)
doc.RenderBlockText(_sampleText)
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
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)
{
doc.StartDoc();
C1.C1Preview.RenderTable theader = new C1.C1Preview.RenderTable(this.c1PrintDocument1);
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);
doc.RenderBlockText(_sampleText);
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();
}
private void c1PrintDocument1_GenerateDocument(object sender, EventArgs e)
{
generateC1PrintDocument(c1PrintDocument1);
} |
See Also