Adds an Image to the Body of the current document at a specific position on the current page, and resolves it.

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

Syntax

C#
public void RenderDirectImage(
	Unit x,
	Unit y,
	Image image,
	Object width,
	Object height,
	ImageAlign imageAlign
)
Visual Basic
Public Sub RenderDirectImage ( _
	x As Unit, _
	y As Unit, _
	image As Image, _
	width As Object, _
	height As Object, _
	imageAlign As ImageAlign _
)

Parameters

x
Type: C1.C1Preview..::..Unit
The horizontal (X) coordinate at which to render the image (cannot be auto).
y
Type: C1.C1Preview..::..Unit
The vertical (Y) coordinate at which to render the image (cannot be auto).
image
Type: System.Drawing..::..Image
The image to render.
width
Type: System..::..Object
The width of the image (if null, auto is used).
height
Type: System..::..Object
The height of the image (if null, auto is used).
imageAlign
Type: C1.C1Preview..::..ImageAlign
The image alignment to use.

Remarks

This method can only be used between calls to StartDoc()()()() and EndDoc()()()() methods on the current document. For details, see RenderDirect(Unit, Unit, RenderObject, Object, Object).

Examples

The following example creates a RenderDirectImage(Unit, Unit, Image, Object, Object, ImageAlign) method to render the image in a specified position:

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)
    ' Render direct image.
    Dim ia As C1.C1Preview.ImageAlign = New C1.C1Preview.ImageAlign()
    ia.KeepAspectRatio = False
    ia.StretchHorz = True
    ia.StretchVert = True
    doc.RenderDirectImage("10%", "10cm", Me.PictureBox1.Image, "80%", "40%", ia)
    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);
    // Render direct image.
    C1.C1Preview.ImageAlign ia = new C1.C1Preview.ImageAlign();
    ia.KeepAspectRatio = false;
    ia.StretchHorz = true;
    ia.StretchVert = true;
    doc.RenderDirectImage("10%", "10cm", this.pictureBox1.Image, "80%", "40%", ia);
    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