Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Use the PDF Printer Settings

  • 2 minutes to read

This example shows how to print a document with custom printer settings.

View Example

using System;
using System.Drawing.Printing;
using System.Windows.Forms;
using DevExpress.Pdf;
using DevExpress.XtraPdfViewer;
//...


private void Form1_Load(object sender, EventArgs e) {
    // Create a PDF Viewer instance and load a PDF into it.
    PdfViewer pdfViewer = this.pdfViewer1;
    pdfViewer.LoadDocument(@"..\..\Demo.pdf");

    // If required, declare and specify the system printer settings
    PrinterSettings printerSettings = new PrinterSettings();
    printerSettings.PrinterName = "Microsoft XPS Document Writer";
    printerSettings.PrintToFile = true;
    printerSettings.PrintFileName = @"..\..\Demo.xps";

    // Declare the PDF printer settings.
    // If required, pass the system settings to the PDF printer settings constructor
    PdfPrinterSettings pdfPrinterSettings = new PdfPrinterSettings(printerSettings);

    // Specify the PDF printer settings
    pdfPrinterSettings.PageOrientation = PdfPrintPageOrientation.Auto;
    pdfPrinterSettings.PageNumbers = new int[] { 1, 3, 4, 5 };
    pdfPrinterSettings.ScaleMode = PdfPrintScaleMode.CustomScale;
    pdfPrinterSettings.Scale = 90;

    // Print the document
    pdfViewer.Print(pdfPrinterSettings);
}