VintaSoft Imaging .NET SDK 12.3: Documentation for .NET developer
Vintasoft.Imaging.Print Namespace / ImagePrintDocument Class
Members Object Syntax Example Hierarchy Requirements SeeAlso
In This Topic
    ImagePrintDocument Class
    In This Topic
    Sends output images to a printer.
    Object Model
    ImagePrintDocument
    Syntax
    'Declaration
    
    <ToolboxBitmapAttribute(Vintasoft.Imaging.Print.PrintScaleMode, null)>
    <ClassInterfaceAttribute(AutoDispatch)>
    <DesignerCategoryAttribute("Component")>
    <DefaultPropertyAttribute("DocumentName")>
    <DefaultEventAttribute("PrintPage")>
    <SRDescriptionAttribute("Defines an object that sends output to a printer.")>
    Public Class ImagePrintDocument
       Inherits System.Drawing.Printing.PrintDocument
    
    
    [ToolboxBitmap(Vintasoft.Imaging.Print.PrintScaleMode, null)]
    [ClassInterface(AutoDispatch)]
    [DesignerCategory("Component")]
    [DefaultProperty("DocumentName")]
    [DefaultEvent("PrintPage")]
    [SRDescription("Defines an object that sends output to a printer.")]
    public class ImagePrintDocument : System.Drawing.Printing.PrintDocument
    
    
    [ToolboxBitmap(Vintasoft.Imaging.Print.PrintScaleMode, null)]
    [ClassInterface(AutoDispatch)]
    [DesignerCategory("Component")]
    [DefaultProperty("DocumentName")]
    [DefaultEvent("PrintPage")]
    [SRDescription("Defines an object that sends output to a printer.")]
    public __gc class ImagePrintDocument : public System.Drawing.Printing.PrintDocument*
    
    
    [ToolboxBitmap(Vintasoft.Imaging.Print.PrintScaleMode, null)]
    [ClassInterface(AutoDispatch)]
    [DesignerCategory("Component")]
    [DefaultProperty("DocumentName")]
    [DefaultEvent("PrintPage")]
    [SRDescription("Defines an object that sends output to a printer.")]
    public ref class ImagePrintDocument : public System.Drawing.Printing.PrintDocument^
    
    
    Example

    This C#/VB.NET code shows 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: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also