PdfViewer.Print(PdfPrinterSettings) Method
Prints the current document using the specified PDF print settings without invoking the Print dialog.
Namespace: DevExpress.XtraPdfViewer
Assembly: DevExpress.XtraPdfViewer.v18.2.dll
Declaration
Parameters
Name | Type | Description |
---|---|---|
pdfPrinterSettings | PdfPrinterSettings | A PdfPrinterSettings value, specifying the PDF printing options. |
Example
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-t171205
using System;
using System.Drawing.Printing;
using System.Windows.Forms;
using DevExpress.Pdf;
using DevExpress.XtraPdfViewer;
namespace PdfPrinterSettingsDemo {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
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 using the specified printer settings.
pdfViewer.Print(pdfPrinterSettings);
}
}
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Print(PdfPrinterSettings) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.