VB.Net/GUI/Print Setting
Версия от 16:40, 26 мая 2010; (обсуждение)
Содержание
- 1 Page setting: paper size, source and resolution
- 2 Page Setting: Top, Bottom, Left, Right Margin and Landscape
- 3 Printer Page Setting: color, Top, Bottom, Left, Right Bound and Top margin
- 4 Printer setting: is print valide, can duplex, Num, Max, Min copies and support color
- 5 Print setting: print name, is default printer, is plotter
- 6 Support paper size and source
Page setting: paper size, source and resolution
Imports System
Imports System.Drawing.Printing
Module Client
Sub Main()
Dim pd As PrintDocument = New PrintDocument()
Dim pg As PageSettings = pd.DefaultPageSettings
Console.WriteLine("PaperSize = " + pg.PaperSize.PaperName)
Console.WriteLine("PaperSource = " + pg.PaperSource.SourceName)
Console.WriteLine("PrinterResolution = " + _
pg.PrinterResolution.Kind.ToString())
Console.WriteLine("PrinterResolution X = " + _
pg.PrinterResolution.X.ToString())
Console.WriteLine("PrinterResolution Y = " + _
pg.PrinterResolution.Y.ToString())
End Sub
End Module
Page Setting: Top, Bottom, Left, Right Margin and Landscape
Imports System
Imports System.Drawing.Printing
Module Client
Sub Main()
Dim pd As PrintDocument = New PrintDocument()
Dim pg As PageSettings = pd.DefaultPageSettings
Console.WriteLine("Top Margin = " + pg.Margins.Top.ToString())
Console.WriteLine("Bottom Margin = " + pg.Margins.Bottom.ToString())
Console.WriteLine("Left Margin = " + pg.Margins.Left.ToString())
Console.WriteLine("Right Margin = " + pg.Margins.Right.ToString())
Console.WriteLine("Landscape = " + pg.Landscape.ToString())
Console.WriteLine("PaperSize = " + pg.PaperSize.PaperName)
Console.WriteLine("PaperSource = " + pg.PaperSource.SourceName)
End Sub
End Module
Printer Page Setting: color, Top, Bottom, Left, Right Bound and Top margin
Imports System
Imports System.Drawing.Printing
Module Client
Sub Main()
Dim pd As PrintDocument = New PrintDocument()
Dim pg As PageSettings = pd.DefaultPageSettings
Console.WriteLine("Is Color = " + pg.Color.ToString())
Console.WriteLine("Top Bound = " + pg.Bounds.Top.ToString())
Console.WriteLine("Bottom Bound = " + pg.Bounds.Bottom.ToString())
Console.WriteLine("Left Bound = " + pg.Bounds.Left.ToString())
Console.WriteLine("Right Bound = " + pg.Bounds.Right.ToString())
End Sub
End Module
Printer setting: is print valide, can duplex, Num, Max, Min copies and support color
Imports System
Imports System.Drawing.Printing
Module Client
Sub Main()
Dim pd As PrintDocument = New PrintDocument()
Dim pg As PageSettings = pd.DefaultPageSettings
Dim ps As PrinterSettings = pg.PrinterSettings
Console.WriteLine("Is printer valid = " + ps.IsValid.ToString())
Console.WriteLine("Can Duplex = " + ps.IsValid.ToString())
Console.WriteLine("Num copies = " + ps.Copies.ToString())
Console.WriteLine("Max Copies = " + ps.MaximumCopies.ToString())
Console.WriteLine("Max Page = " + ps.MaximumPage.ToString())
Console.WriteLine("Min Page = " + ps.MinimumPage.ToString())
Console.WriteLine("Supports Color = " + ps.SupportsColor.ToString())
End Sub
End Module
Print setting: print name, is default printer, is plotter
Imports System
Imports System.Drawing.Printing
Module Client
Sub Main()
Dim pd As PrintDocument = New PrintDocument()
Dim pg As PageSettings = pd.DefaultPageSettings
Dim ps As PrinterSettings = pg.PrinterSettings
Console.WriteLine("PrinterName = " + pd.PrinterSettings.PrinterName)
Console.WriteLine("Is default Printer = " + _
ps.IsDefaultPrinter.ToString())
Console.WriteLine("Is plotter = " + ps.IsPlotter.ToString())
End Sub
End Module
Support paper size and source
Imports System
Imports System.Drawing.Printing
Module Client
Sub Main()
Dim pd As PrintDocument = New PrintDocument()
Dim pg As PageSettings = pd.DefaultPageSettings
Dim ps As PrinterSettings = pg.PrinterSettings
Dim p As PaperSize
For Each p In ps.PaperSizes
Console.WriteLine("Supports Paper Size: " + p.PaperName)
Next
Dim p1 As PaperSource
For Each p1 In ps.PaperSources
Console.WriteLine("Supports Paper Source: " + p1.SourceName)
Next
End Sub
End Module