Resizing or Scaling an Image
You can easily resize or scale a RenderImage to 50% by completing the following steps:
1. From the Toolbox, add the C1PrintPreviewControl and C1PrintDocument components to your project.
2. Click C1PrintPreviewControl1 to select it, and in the Properties window set its Document property to C1PrintDocument1.
3. Switch to Code view and add the following namespace declaration:
Imports C1.C1Preview
• C#
using C1.C1Preview;
4. Add the following Form_Load event, which adds an image to the page and scales that image to 50% of the available width with the height scaling automatically, replacing c1logo.png with your image name and location:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Create a new Render Image, replacing c1logo.png with your image name and location.
Dim img As New C1.C1Preview.RenderImage
img.Image = Image.FromFile("C:\c1logo.png")
' Scale the image to 50% of the available page width, the height of the image will scale automatically here.
img.Width = "50%"
' Create the document.
C1PrintDocument1.StartDoc()
C1PrintDocument1.RenderBlock(img)
C1PrintDocument1.EndDoc()
End Sub
• C#
private void Form1_Load(object sender, EventArgs e)
{
// Create a new Render Image, replacing c1logo.png with your image name and location.
C1.C1Preview.RenderImage img = new C1.C1Preview.RenderImage();
img.Image = Image.FromFile("C:\\c1logo.png");
// Scale the image to 50% of the available page width, the height of the image will scale automatically here.
img.Width = "50%";
// Create the document.
c1PrintDocument1.StartDoc();
c1PrintDocument1.RenderBlock(img);
c1PrintDocument1.EndDoc();
}
What You've Accomplished
A image appears scaled on the page:
|