How to: Use the PDF Printer Settings
- 2 minutes to read
Important
You need a license to the DevExpress Office File API or DevExpress Universal Subscription to use these examples in production code. Refer to the DevExpress Subscription page for pricing information.
This example shows how to print a document with custom printer settings.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-use-the-pdf-printer-settings-t172274
// Developer Express Code Central Example:
// How to use the PDF printer settings
using DevExpress.Pdf;
namespace PdfProcessorPrinterOptions
{
class Program
{
static void Main(string[] args)
{
// Create a Pdf Document Processor instance and load a PDF into it.
PdfDocumentProcessor documentProcessor = new PdfDocumentProcessor();
documentProcessor.LoadDocument(@"..\..\Demo.pdf");
// Declare the PDF printer settings.
PdfPrinterSettings pdfPrinterSettings = new PdfPrinterSettings();
// Specify the PDF printer settings.
pdfPrinterSettings.PageOrientation = PdfPrintPageOrientation.Portrait;
pdfPrinterSettings.PageNumbers = new int[] { 1, 3, 4, 5 };
// Specify the custom scale number
pdfPrinterSettings.ScaleMode = PdfPrintScaleMode.CustomScale;
pdfPrinterSettings.Scale = 90;
//Specify .NET printer settings
PrinterSettings settings = printerSettings.Settings;
settings.Duplex = Duplex.Vertical;
settings.Copies = 3;
// Print the document using the specified printer settings.
documentProcessor.Print(pdfPrinterSettings);
}
}
}
Important
The Print method works only on Windows OS. The PlatformNotSupportedException is thrown on other operating systems.
See Also