VintaSoft Imaging .NET SDK 15.1: Документация для .NET разработчика
Vintasoft.Imaging.Print Namespace / ImagePrintDocument Class
Члены типа Объект Синтаксис Example Иерархия Требования Смотрите также
В этом разделе
Класс ImagePrintDocument
В этом разделе
Отправляет выходные изображения на принтер.
Объектная модель
ImagePrintDocument
Синтаксис
'Declaration

<ToolboxBitmapAttribute("", 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("", 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

Пример

Вот C#/VB.NET код, который демонстрирует, как распечатать многостраничный TIFF файл. Размер каждого изображения будет изменен, чтобы заполнить страницу.


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

}

Иерархия наследования

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

Требования

Целевые платформы: .NET 10; .NET 9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

Смотрите также