Table of Contents

Class PrintDocument

Namespace
Alternet.Drawing.Printing
Assembly
Alternet.UI.Common.dll

Defines a reusable object that sends output to a printer, when printing from an AlterNET UI application.

public class PrintDocument : HandledObject<IPrintDocumentHandler>, IBaseObjectWithAttr, IBaseObjectWithId, INotifyPropertyChanged, IImmutableObject, IDisposableObject, IDisposable, IBaseObject
Inheritance
PrintDocument
Implements

Remarks

Typically, you create an instance of the PrintDocument class, set properties such as the DocumentName and PrinterSettings, and call the Print() method to start the printing process. Handle the PrintPage event where you specify the output to print, by using the DrawingContext property of the PrintPageEventArgs.

Constructors

PrintDocument()

Initializes a new instance of the PrintDocument class.

Properties

CurrentDrawingContext

Gets the current graphics drawing context used for printing operations.

DocumentName

Gets or sets the document name to display (for example, in a print status dialog box or printer queue) while printing the document.

IsCurrentPrinting

Gets a value indicating whether a print operation is currently in progress.

OriginAtMargins

Gets or sets a value indicating whether the position of a graphics object associated with a page is located just inside the user-specified margins or at the top-left corner of the printable area of the page.

PageSettings

Gets or sets page settings that are used for all pages to be printed.

PrinterSettings

Gets the printer settings for this document.

Methods

CreateHandler()

Creates handler.

DisposeManaged()

Override to dispose managed resources. Here we dispose all used object references.

Log(ILogWriter?)

Logs the document, page and printer settings using the specified log writer.

OnBeginPrint(PrintEventArgs)

Raises the BeginPrint event. It is called after the Print() method is called and before the first page of the document prints.

OnEndPrint(PrintEventArgs)

Raises the EndPrint event. It is called when the last page of the document has printed.

OnNativePrintDocumentBeginPrint(object?, CancelEventArgs)

Raises the event signaling the start of a native print document operation.

OnNativePrintDocumentEndPrint(object?, CancelEventArgs)

Handles the completion of a native print document operation and updates the cancellation status based on the print event arguments.

OnNativePrintDocumentPrintPage(object?, CancelEventArgs)

Handles the print page event for the native print document, raising the print page logic and updating the cancellation status as needed.

OnPrintPage(PrintPageEventArgs)

Raises the PrintPage event. It is called before a page prints.

Print()

Starts the document's printing process.

ThrowIfPrintingInProgress()

Throws an exception if a printing operation is currently in progress.

Events

BeginPrint

Occurs when the Print() method is called and before the first page of the document prints.

EndPrint

Occurs when the last page of the document has printed.

PrintPage

Occurs when the output to print for the current page is needed.