PdfViewer.QueryPageSettings Event
Occurs before the PdfViewer.PrintPage event.
Namespace: DevExpress.XtraPdfViewer
Assembly: DevExpress.XtraPdfViewer.v23.2.dll
NuGet Package: DevExpress.Win.PdfViewer
Declaration
Event Data
The QueryPageSettings event's data class is PdfQueryPageSettingsEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Cancel | Gets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs. |
PageNumber | Gets the page number in a document. |
PageSettings | Gets or sets the page settings for the page to be printed. Inherited from QueryPageSettingsEventArgs. |
PageSize | Gets the size of the current page. |
PrintAction | Returns PrintToFile in all cases. Inherited from PrintEventArgs. |
PrintInGrayscale | Gets or sets a value which indicates whether to print the document content in grayscale. |
Remarks
Handle the QueryPageSettings
event to specify print settings for a specific page.
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.
pdfViewer.QueryPageSettings += PdfViewer_QueryPageSettings;
pdfViewer.PrintPage += OnPrintPage;
//...
private void PdfViewer_QueryPageSettings(object sender, PdfQueryPageSettingsEventArgs e)
{
// Print the second page in landscape size.
if (e.PageNumber == 2)
{
e.PageSettings.Landscape = true;
}
else e.PageSettings.Landscape = false;
}
private static void OnPrintPage(object sender, 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));
}
See Also