public class PrintDocumentAdvanced : IDisposable
Public Class PrintDocumentAdvanced
Implements IDisposable
Dim instance As PrintDocumentAdvanced
public ref class PrintDocumentAdvanced : IDisposable
type PrintDocumentAdvanced =
class
interface IDisposable
end
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
Public Module Module1
Private printExpert As PrintDocumentAdvanced
Public Sub Main()
printExpert = New PrintDocumentAdvanced("C:\Document.txt", Encoding.Default)
Using printExpert
printExpert.PrinterSettings = New PrinterSettings With {
.PrinterName = "My Printer Name"
}
printExpert.BeginPrintEventHandler = AddressOf PrintDocument_BeginPrint
printExpert.QueryPageSettingsEventHandler = AddressOf PrintDocument_QueryPageSettings
printExpert.PrintPageEventHandler = AddressOf PrintDocument_PrintPage
printExpert.EndPrintEventHandler = AddressOf PrintDocument_EndPrint
printExpert.Print()
End Using
End Sub
Public Sub PrintDocument_BeginPrint(ByVal sender As Object, ByVal e As PrintEventArgs)
End Sub
Public Sub PrintDocument_QueryPageSettings(ByVal sender As Object, ByVal e As QueryPageSettingsEventArgs)
End Sub
Public Sub PrintDocument_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs)
' Page settings.
Dim font As New Font("Arial", 10.0F, FontStyle.Regular)
Dim brush As New SolidBrush(Color.Green)
Dim stringFormat As New StringFormat()
Dim leftMargin As Single = e.MarginBounds.Left
Dim topMargin As Single = e.MarginBounds.Top
' Calculate the number of lines per page.
Dim linesPerPage As Single = (e.MarginBounds.Height / font.GetHeight(e.Graphics))
' Iterate over the file, printing each line.
Dim line As String = Nothing
Dim count As Integer
While (count < linesPerPage)
line = printExpert.DocumentStream.ReadLine()
If (line Is Nothing) Then
Exit While
End If
Dim yPos As Single = (topMargin + count * font.GetHeight(e.Graphics))
e.Graphics.DrawString(line, font, brush, leftMargin, yPos, stringFormat)
count += 1
End While
font.Dispose()
brush.Dispose()
stringFormat.Dispose()
' If more lines exist, print another page.
e.HasMorePages = (line IsNot Nothing)
End Sub
Public Sub PrintDocument_EndPrint(ByVal sender As Object, ByVal e As PrintEventArgs)
End Sub
End Module
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
PrintDocumentAdvanced(String) | Initializes a new instance of the PrintDocumentAdvanced class. |
PrintDocumentAdvanced(String, Encoding) | Initializes a new instance of the PrintDocumentAdvanced class. |
BeginPrintEventHandler | Gets or sets the PrintEventHandler delegate method to handle the BeginPrint event. |
DocumentStream | Gets or sets the StreamReader instance that encapsulates the document data to be read and printed. |
Encoding | Gets or sets the text encoding. If no encoding is specified, the default system encoding will be used. |
EndPrintEventHandler | Gets or sets the PrintEventHandler delegate method to handle the BeginPrint event. |
Filepath | Gets the document file path. |
PrinterSettings | Gets or sets the PrinterSettings instance that specifies information about how a document is printed, including the printer that prints it. |
PrintPageEventHandler | Gets or sets the PrintPageEventHandler delegate method to handle the PrintPage event. |
QueryPageSettingsEventHandler | Gets or sets the QueryPageSettingsEventHandler delegate method to handle the BeginPrint event. |
CancelPrint | Cancels the print job for the current document. |
Dispose | Releases all the resources used by this PrintDocumentBasic instance. |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object) |
GetHashCode | Serves as the default hash function. (Inherited from Object) |
GetType | Gets the Type of the current instance. (Inherited from Object) |
Prints the current document. | |
ToString | Returns a string that represents the current object. (Inherited from Object) |
CanConvertTo |
Determines whether the source object can be converted to the specified target type.
(Defined by ObjectExtensions) |
CanConvertToT |
Determines whether the source object can be converted to the specified target type.
(Defined by ObjectExtensions) |
ConvertToT |
Converts an object to the specified target type.
If the conversion fails, an exception is thrown.
(Defined by ObjectExtensions) |
ConvertToT |
Converts an object to the specified target type.
If the conversion fails, returns the specified default value.
(Defined by ObjectExtensions) |
IsDisposable |
Determines whether the specified object is a disposable type
(i.e., it implements IDisposable interface).
(Defined by ObjectExtensions) |
Speak |
Speaks the string representation of the source object by using the
operating system integrated text-to-speech synthesizer.
(Defined by ObjectExtensions) |
Speak |
Speaks the string representation of the source object by using the
operating system integrated text-to-speech synthesizer.
(Defined by ObjectExtensions) |
ThrowIfNullTException |
Throws the specified exception if the source object is null.
(Defined by ObjectExtensions) |