LEADTOOLS WPF and Silverlight (Leadtools.Windows.Controls assembly)
LEAD Technologies, Inc

PrinterHelper Class

Example 





Members 
Supports printing for images inside an Leadtools.Windows.Controls.ImageBox, Leadtools.Windows.Controls.RasterImageBox, Leadtools.Windows.Controls.ImageViewer or Leadtools.Windows.Controls.RasterImageViewer controls. .NET support
Object Model
PrinterHelper Class
Syntax
public class PrinterHelper 
'Declaration
 
Public Class PrinterHelper 
'Usage
 
Dim instance As PrinterHelper
public sealed class PrinterHelper 
function Leadtools.Windows.Printing.PrinterHelper()
public ref class PrinterHelper 
Remarks

The PrinterHelper class provides properties and method to make the process of printing an image in a Leadtools.Windows.Controls.ImageBox, Leadtools.Windows.Controls.RasterImageBox, Leadtools.Windows.Controls.ImageViewer or Leadtools.Windows.Controls.RasterImageViewer controls.

PrinterHelper can be used in the following ways:

The following are examples on how to print a LEADTOOLS image viewer control in Silverlight 4 or later:

    
             // Silverlight 4 Example with printing using PrinterHelper directly
             // MyImageViewer is an instance of "Leadtools.Windows.Controls.ImageViewer"
             PrinterHelper helper = new PrinterHelper();
             helper.Destination = new Rect(0, 0, 1, 1);
             helper.IsDestinationRelative = true;
             helper.Print(MyImageViewer, "My Document");
             

  

    
             // Silverlight 4 Example with printing using PrintDocument
             // MyImageViewer is an instance of "Leadtools.Windows.Controls.ImageViewer"
             PrintDocument pd = new PrintDocument();
             pd.PrintPage += new EventHandler<PrintPageEventArgs>(pd_PrintPage);
             pd.Print("My Document");
            
             // This is the PrintDocument PrintPage handler:
             private void pd_PrintPage(object sender, PrintPageEventArgs e)
             {
                PrinterHelper ph = new PrinterHelper();
                e.PageVisual = ph.CreateCanvas(MyImageViewer, e);
                (sender as PrintDocument).PrintPage -= new EventHandler<PrintPageEventArgs>(pd_PrintPage);
             }
             

  

Example
Copy CodeCopy Code  
Private Sub PrintViewerExample(ByVal viewer As ImageViewer)
   ' Print the image in the viewer, fill the page and center horizontall and vertically
   Dim ph As New PrinterHelper()
   ph.Destination = New Rect(0, 0, 1, 1)
   ph.IsDestinationRelative = True
   ph.HorizontalAlignment = HorizontalAlignment.Center
   ph.VerticalAlignment = VerticalAlignment.Center
   ph.ImageStretch = Stretch.UniformToFill

   ph.Print(viewer, "My Document")
End Sub
private void PrintViewerExample(ImageViewer viewer)
{
   // Print the image in the viewer, fill the page and center horizontall and vertically
   PrinterHelper ph = new PrinterHelper();
   ph.Destination = new Rect(0, 0, 1, 1);
   ph.IsDestinationRelative = true;
   ph.HorizontalAlignment = HorizontalAlignment.Center;
   ph.VerticalAlignment = VerticalAlignment.Center;
   ph.ImageStretch = Stretch.UniformToFill;

   ph.Print(viewer, "My Document");
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

PrinterHelper Members
Leadtools.Windows.Printing Namespace

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.