VintaSoft Imaging .NET SDK v8.6
Vintasoft.Imaging.Print Namespace / ImagePrintDocument Class
Members Example



In This Topic
    ImagePrintDocument Class
    In This Topic
    Sends output images to a printer.
    Object Model
    ImagePrintDocument Class
    Syntax
    'Declaration
     
    <ToolboxBitmapAttribute()>
    <ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)>
    <DesignerCategoryAttribute("Component")>
    Public Class ImagePrintDocument 
       Inherits System.Drawing.Printing.PrintDocument
    [ToolboxBitmap()]
    [ClassInterface(ClassInterfaceType.AutoDispatch)]
    [DesignerCategory("Component")]
    public class ImagePrintDocument : System.Drawing.Printing.PrintDocument 
    [ToolboxBitmap()]
    [ClassInterface(ClassInterfaceType.AutoDispatch)]
    [DesignerCategory("Component")]
    public __gc class ImagePrintDocument : public System.Drawing.Printing.PrintDocument 
    [ToolboxBitmap()]
    [ClassInterface(ClassInterfaceType.AutoDispatch)]
    [DesignerCategory("Component")]
    public ref class ImagePrintDocument : public System.Drawing.Printing.PrintDocument 
    Example
    This example demonstrates how to print a multipage TIFF file. Each image will be resized to fill the page.
    Public Class Form1
        Inherits System.Windows.Forms.Form
                
        #Region "Fields"
                
        Private _currentPage As Integer
        Private _imageCollection1 As Vintasoft.Imaging.ImageCollection
                
        #End Region
                
                
                
        #Region "Constructors"
                
        Public Sub New()
            Dim imagePrintDocument1 As New Vintasoft.Imaging.Print.ImagePrintDocument()
            imagePrintDocument1.PrintScaleMode = Vintasoft.Imaging.Print.PrintScaleMode.BestFit
            imagePrintDocument1.Center = True
            AddHandler imagePrintDocument1.PrintImage, New System.EventHandler(Of Vintasoft.Imaging.Print.PrintImageEventArgs)(AddressOf imagePrintDocument1_PrintImage)
                
            _imageCollection1 = New Vintasoft.Imaging.ImageCollection()
            _imageCollection1.Add("c:\multipage.tif")
                
            Dim printDialog1 As New System.Windows.Forms.PrintDialog()
            printDialog1.Document = imagePrintDocument1
            If printDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
                ' do not use margins
                Dim pageMargins As New System.Drawing.Printing.Margins(0, 0, 0, 0)
                imagePrintDocument1.DefaultPageSettings.Margins = pageMargins
                
                ' print the image
                imagePrintDocument1.Print()
            End If
        End Sub
                
        #End Region
                
                
                
        #Region "Methods"
                
        ' The PrintImage event is raised for each page to be printed.
        Private Sub imagePrintDocument1_PrintImage(sender As Object, e As Vintasoft.Imaging.Print.PrintImageEventArgs)
            If _currentPage < _imageCollection1.Count Then
                e.Image = _imageCollection1(_currentPage)
                
                _currentPage += 1
                If _currentPage >= _imageCollection1.Count Then
                    e.HasMoreImages = False
                    _currentPage = 0
                Else
                    e.HasMoreImages = True
                End If
            End If
        End Sub
                
        #End Region
                
    End Class
    public class Form1 : System.Windows.Forms.Form
    {
                
        #region Fields
                
        int _currentPage;
        Vintasoft.Imaging.ImageCollection _imageCollection1;
                
        #endregion
                
                
                
        #region Constructors
                
        public Form1()
        {
            Vintasoft.Imaging.Print.ImagePrintDocument imagePrintDocument1 =
                new Vintasoft.Imaging.Print.ImagePrintDocument();
            imagePrintDocument1.PrintScaleMode = Vintasoft.Imaging.Print.PrintScaleMode.BestFit;
            imagePrintDocument1.Center = true;
            imagePrintDocument1.PrintImage +=
                new System.EventHandler<Vintasoft.Imaging.Print.PrintImageEventArgs>(imagePrintDocument1_PrintImage);
                
            _imageCollection1 = new Vintasoft.Imaging.ImageCollection();
            _imageCollection1.Add(@"c:\multipage.tif");
                
            System.Windows.Forms.PrintDialog printDialog1 = new System.Windows.Forms.PrintDialog();
            printDialog1.Document = imagePrintDocument1;
            if (printDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                // do not use margins
                System.Drawing.Printing.Margins pageMargins =
                    new System.Drawing.Printing.Margins(0, 0, 0, 0);
                imagePrintDocument1.DefaultPageSettings.Margins = pageMargins;
                
                // print the image
                imagePrintDocument1.Print();
            }
        }
                
        #endregion
                
                
                
        #region Methods
                
        // The PrintImage event is raised for each page to be printed.
        void imagePrintDocument1_PrintImage(object sender, Vintasoft.Imaging.Print.PrintImageEventArgs e)
        {
            if (_currentPage < _imageCollection1.Count)
            {
                e.Image = _imageCollection1[_currentPage];
                
                _currentPage++;
                if (_currentPage >= _imageCollection1.Count)
                {
                    e.HasMoreImages = false;
                    _currentPage = 0;
                }
                else
                {
                    e.HasMoreImages = true;
                }
            }
        }
                
        #endregion
                
    }
    Inheritance Hierarchy

    System.Object
       System.MarshalByRefObject
          System.ComponentModel.Component
             System.Drawing.Printing.PrintDocument
                Vintasoft.Imaging.Print.ImagePrintDocument
                   Vintasoft.Imaging.Annotation.Print.AnnotatedImagePrintDocument
                   Vintasoft.Imaging.Pdf.Print.PdfPrintDocument

    Requirements

    Target Platforms: Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also