ImageGear .NET v24.14 - Updated September 15, 2020
Print Method (ImGearPageDisplay)
Example 




ImageGear24.Core Assembly > ImageGear.Display Namespace > ImGearPageDisplay Class : Print Method
Graphics object to draw the image on.
Draws the image on .NET Graphics for printing. Call to Print(hdc) is equal to call DrawEx(null, hdc, true).
Syntax
'Declaration
 
Public Sub Print( _
   ByVal graphics As Graphics _
) 
 
'Usage
 
Dim instance As ImGearPageDisplay
Dim graphics As Graphics
 
instance.Print(graphics)

Parameters

graphics
Graphics object to draw the image on.
Example
private void PrintPage(object sender, EventArgs e)
{
    // Load an image
    ImGearPage igPage;
    using (FileStream localFile = new FileStream("test1.tif", FileMode.Open))
    {
        igPage = ImGearFileFormats.LoadPage(localFile, 0);
    }
    // Create a new ImGearPageDisplay based upon an ImGearPage.
    ImGearPageDisplay igPageDisplay = new ImGearPageDisplay(igPage);
    // Set the current ImGearPageView to use this new display.
    imGearPageView.Display = igPageDisplay;
    // Initialize a PrintDialog for the user to select a printer.
    using (PrintDocument document = new PrintDocument())
    using (PrintDialog printDialog = new PrintDialog())
    {
        printDialog.Document = document;
        // Set the page range to 1 page.
        printDialog.AllowSomePages = true;
        printDialog.PrinterSettings.MinimumPage = 1;
        printDialog.PrinterSettings.MaximumPage = 1;
        printDialog.PrinterSettings.FromPage = 1;
        printDialog.PrinterSettings.ToPage = 1;
        
        if (DialogResult.OK == printDialog.ShowDialog(this))
        {
            // Set a name for the print job.
            document.DocumentName = this.Text;
            // Define a PrintPage event handler and start printing.
            document.PrintPage +=
                new PrintPageEventHandler(HandlePrinting);
            document.Print();
        }
    }
}

void HandlePrinting(object sender, PrintPageEventArgs args)
{
    // Clone the current Display for use as a printing display.
    ImGearPageDisplay igPageDisplayPrinting =
        imGearPageView.Display.Clone();
    igPageDisplayPrinting.Page = imGearPageView.Display.Page;
    // Get the current Zoom settings and disabled fixed zoom.
    ImGearZoomInfo igZoomInfo =
        igPageDisplayPrinting.GetZoomInfo(imGearPageView);
    igZoomInfo.Horizontal.Fixed =
        igZoomInfo.Vertical.Fixed = false;
    igPageDisplayPrinting.UpdateZoomFrom(igZoomInfo);
    // Disable any background before printing.
    igPageDisplayPrinting.Background.Mode =
        ImGearBackgroundModes.NONE;
    // Print to the Graphics device chosen from the PrintDialog.
    igPageDisplayPrinting.Print(args.Graphics);
    // Let the PrintDialog know there are no more pages.
    args.HasMorePages = false;
}
See Also

Reference

ImGearPageDisplay Class
ImGearPageDisplay Members