ImagePrintDocument Constructor()
В этом разделе
Инициализирует новый экземпляр класса
ImagePrintDocument.
Синтаксис
'Declaration
Public Function New()
public ImagePrintDocument()
public: ImagePrintDocument()
public:
ImagePrintDocument()
Пример
Вот 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
}
Требования
Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5
Смотрите также