Skip to main content
You are viewing help content for pre-release software. This document and the features it describes are subject to change.
All docs
V26.1
  • Print PDF Documents with New PDF Document API Library

    • 2 minutes to read

    This document describes how to print PDF documents with the DevExpress PDF Document API library on different operating systems.

    Call the PdfDocument.Print method and pass a PrintOptions object as a parameter.

    The following code snippet prints a PDF file using the default printer:

    using DevExpress.Docs.Pdf;
    using DevExpress.Docs.Pdf.Printing;
    using System.IO;
    
    using (PdfDocument pdfDocument = new PdfDocument(
        new FileStream(@"C:\Test Documents\Document.pdf", FileMode.Open, FileAccess.ReadWrite))) {
    
        PrintOptions pdfPrinterSettings = new PrintOptions();
    
        pdfPrinterSettings.PageOrientation = PrintPageOrientation.Portrait;
        pdfPrinterSettings.PrintStickyNotes = false;
    
        pdfDocument.Print(pdfPrinterSettings);
    }
    

    Use the PrintOptions.PrinterSettings property to obtain printing settings that can be used to print PDF files in non-Windows environments (macOS and Unix-based systems that support printing through Common UNIX Printing System (CUPS)).

    The following code snippet specifies cross-platform printing settings and prints the PDF file:

    using DevExpress.Docs.Pdf;
    using DevExpress.Docs.Pdf.Printing;
    using DevExpress.Drawing.Printing;
    using System.IO;
    
    using (PdfDocument pdfDocument = new PdfDocument(
        new FileStream(@"C:\Test Documents\Document.pdf", FileMode.Open, FileAccess.ReadWrite))) {
    
        PrintOptions pdfPrinterSettings = new PrintOptions();
    
        DXPrinterSettings dxPrinterSettings = pdfPrinterSettings.PrinterSettings;
        dxPrinterSettings.PrinterName = "myPrinter";
        dxPrinterSettings.PageRange = "1-3,5";
        dxPrinterSettings.Duplex = DXDuplexMode.DuplexLongEdge;
        dxPrinterSettings.Copies = 3;
    
        pdfDocument.Print(pdfPrinterSettings);
    }