вот часть кода
- Код: Выделить всё
Private prnDoc1 As PrintDocument
Private pageset As New PageSettings
Private prnset As New PrinterSettings
Private Sub frmPrint_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
prnDoc1 = New PrintDocument
prnset.PrinterName = PrinterSettings.InstalledPrinters(0)
pageset.Margins = New Margins(0, 0, 0, 0)
pageset = New PageSettings(prnset)
prnDoc1.DefaultPageSettings = pageset
ppvc.Document = prnDoc1
Dim ppc As New PreviewPrintController
prnDoc1.PrintController = ppc
Dim pSize As PaperSize
For Each pSize In pageset.PrinterSettings.PaperSizes
If pSize.Kind = PaperKind.A4 Then
pageset.PaperSize = pSize
Exit For
End If
Next
prnDoc1.PrinterSettings = prnset
prnDoc1.DocumentName = ""
AddHandler prnDoc1.PrintPage, AddressOf PrintPage
End Sub