PdfPrintPageEventArgs.PageNumber Property
Returns the page number of the currently printed page.
Namespace: DevExpress.Pdf
Assembly: DevExpress.Pdf.v24.1.Drawing.dll
NuGet Package: DevExpress.Pdf.Drawing
Declaration
Property Value
Type | Description |
---|---|
Int32 | An integer value that is the page number. |
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.Pdf;
using System.Drawing;
// Create a PDF Document Processor instance and load a PDF file
using (PdfDocumentProcessor documentProcessor = new PdfDocumentProcessor()) {
documentProcessor.LoadDocument(@"..\..\Demo.pdf");
// Declare PDF printer settings.
PdfPrinterSettings settings = new PdfPrinterSettings();
// Specify the page numbers to be printed.
settings.PageNumbers = new int[] { 1, 2, 3, 4, 5, 6 };
// Handle the PrintPage event to specify print output.
documentProcessor.PrintPage += OnPrintPage;
// Handle the QueryPageSettings event to customize settings for a page to be printed.
documentProcessor.QueryPageSettings += OnQueryPageSettings;
// Print the document using the specified printer settings.
documentProcessor.Print(settings);
// Unsubscribe from PrintPage and QueryPageSettings events.
documentProcessor.PrintPage -= OnPrintPage;
documentProcessor.QueryPageSettings -= OnQueryPageSettings;
}
private static void OnQueryPageSettings(object sender, PdfQueryPageSettingsEventArgs e) {
// Print the second page in landscape size.
if (e.PageNumber == 2) {
e.PageSettings.Landscape = true;
}
else e.PageSettings.Landscape = false;
}
// Specify what happens when the PrintPage event is raised.
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