PdfViewerControl.PrintPage Event
Occurs when the document page is printed.
Namespace: DevExpress.Xpf.PdfViewer
Assembly: DevExpress.Xpf.PdfViewer.v24.2.dll
NuGet Package: DevExpress.Wpf.PdfViewer
#Declaration
public event PdfPrintPageEventHandler PrintPage
#Event Data
The PrintPage event's data class is PdfPrintPageEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Cancel | Gets or sets a value indicating whether the print job should be canceled. |
Graphics | Gets the Graphics used to paint the page |
Handled |
Gets or sets a value that indicates the present state of the event handling for a routed event as it travels the route.
Inherited from Routed |
Has |
Gets or sets a value indicating whether an additional page should be printed. |
Margin |
Returns the rectangular area that represents the portion of the page inside the margins. |
Original |
Gets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class.
Inherited from Routed |
Page |
Returns the rectangular area that represents the total area of the page. |
Page |
Returns the total number of pages sent to the printer. |
Page |
Returns the page number of the currently printed page. |
Page |
Gets the page settings for the current page. |
Routed |
Gets or sets the Routed |
Source |
Gets or sets a reference to the object that raised the event.
Inherited from Routed |
The event data class exposes the following methods:
Method | Description |
---|---|
Invoke |
When overridden in a derived class, provides a way to invoke event handlers in a type-specific way, which can increase efficiency over the base implementation.
Inherited from Routed |
On |
When overridden in a derived class, provides a notification callback entry point whenever the value of the Source property of an instance changes.
Inherited from Routed |
#Remarks
Use this event to perform actions when the document is sent to a printer. For example, the current page number and the total number of pages can be accessed via the PdfPrintPageEventArgs.PageNumber and PdfPrintPageEventArgs.PageCount properties, respectively.
#Example
The code snippet below handles the QueryPageSettings
and PrintPage
events to specify the landscape orientation for a second page and add an image on each printed page.
using DevExpress.Xpf.PdfViewer;
using System.Drawing;
//...
private void pdfViewer_QueryPageSettings(DependencyObject d, PdfQueryPageSettingsEventArgs e)
{
// Print the second page in landscape size.
if (e.PageNumber == 2)
{
e.PageSettings.Landscape = true;
}
else e.PageSettings.Landscape = false;
}
private void pdfViewer_PrintPage(DependencyObject d, PdfPrintPageEventArgs e)
{
// Draw a picture on each printed page.
using (Bitmap image = new Bitmap(@"..\..\DevExpress.png"))
e.Graphics.DrawImage(image, new RectangleF(10, 30, image.Width / 2, image.Height / 2));
}