Supports printing of an
RasterImage
Syntax
Visual Basic (Declaration) | |
---|
Public Class RasterImagePrinter |
C# | |
---|
public class RasterImagePrinter |
Managed Extensions for C++ | |
---|
public __gc class RasterImagePrinter |
C++/CLI | |
---|
public ref class RasterImagePrinter |
Example
This example loads an image and then sends it to the printer.
Visual Basic | Copy Code |
---|
Public myImage As RasterImage = Nothing
Public Sub RasterImagePrinter_RasterImagePrinter()
RasterCodecs.Startup()
Dim codecs As RasterCodecs = New RasterCodecs()
myImage = codecs.Load("C:\program files\LEAD Technologies\LEADTOOLS 15\Images\clean.tif")
RasterCodecs.Shutdown()
If Not PrinterSettings.InstalledPrinters Is Nothing AndAlso PrinterSettings.InstalledPrinters.Count > 0 Then
Dim printDocument As PrintDocument = New PrintDocument()
AddHandler printDocument.PrintPage, AddressOf printDocument_PrintPage
printDocument.Print()
End If
myImage.Dispose()
End Sub
Private Sub printDocument_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs)
Dim printer As RasterImagePrinter = New RasterImagePrinter()
printer.SizeMode = RasterPaintSizeMode.Fit
printer.HorizontalAlignMode = RasterPaintAlignMode.Center
printer.VerticalAlignMode = RasterPaintAlignMode.Center
printer.UseDpi = True
printer.ImageRectangle = Rectangle.Empty
printer.PageRectangle = RectangleF.Empty
Dim props As RasterPaintProperties = RasterPaintProperties.Default
props.PaintEngine = RasterPaintEngine.Gdi
props.PaintDisplayMode = props.PaintDisplayMode Or RasterPaintDisplayModeFlags.ScaleToGray
printer.PaintProperties = props
printer.Print(myImage, myImage.Page, e)
End Sub |
C# | Copy Code |
---|
public RasterImage myImage = null; public void RasterImagePrinter_RasterImagePrinter() { // load an image RasterCodecs.Startup(); RasterCodecs codecs = new RasterCodecs(); myImage = codecs.Load(@"C:\program files\LEAD Technologies\LEADTOOLS 15\Images\clean.tif"); RasterCodecs.Shutdown(); if(PrinterSettings.InstalledPrinters != null && PrinterSettings.InstalledPrinters.Count > 0) { PrintDocument printDocument = new PrintDocument(); printDocument.PrintPage += new PrintPageEventHandler(printDocument_PrintPage); printDocument.Print(); } // dispose the image myImage.Dispose(); } private void printDocument_PrintPage(object sender, PrintPageEventArgs e) { RasterImagePrinter printer = new RasterImagePrinter(); // We want normal size (not zoomed) but centered printer.SizeMode = RasterPaintSizeMode.Fit; printer.HorizontalAlignMode = RasterPaintAlignMode.Center; printer.VerticalAlignMode = RasterPaintAlignMode.Center; // Account for image resolution printer.UseDpi = true; // print the whole image printer.ImageRectangle = Rectangle.Empty; // use maximum page printer.PageRectangle = RectangleF.Empty; // Win32 GDI printing and scale to gray RasterPaintProperties props = RasterPaintProperties.Default; props.PaintEngine = RasterPaintEngine.Gdi; props.PaintDisplayMode |= RasterPaintDisplayModeFlags.ScaleToGray; printer.PaintProperties = props; printer.Print(myImage, myImage.Page, e); } |
Remarks
Inheritance Hierarchy
Requirements
Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also