Print PDF pages to booklet in C#

Booklets are usually used when we print huge PDF files. It saves paper and make the pages tidy. Starts from Spire.PDF V5.12.3, Spire.PDF supports to print the PDF pages to booklet directly. This article demonstrates how to print PDF pages to booklet in C#.

using Spire.Pdf;
using Spire.Pdf.Actions;
using Spire.Pdf.General;
using Spire.Pdf.Print;

namespace PDFPrintBookLet
{
    class Program
    {
        static void Main(string[] args)
        {
            //Load the sample document
            PdfDocument doc = new PdfDocument();
            doc.LoadFromFile("Sample.pdf");

            //Set booklet layout when print the pdf files
            PdfBookletSubsetMode bookletSubset = PdfBookletSubsetMode.BothSides;
            PdfBookletBindingMode bookletBinding = PdfBookletBindingMode.Left;
            doc.PrintSettings.SelectBookletLayout(bookletSubset, bookletBinding);

            //Print PDF to virtual printer
            doc.PrintSettings.PrinterName = "Microsoft XPS Document Writer";
            doc.PrintSettings.PrintToFile("XpsBooklet.xps");
            doc.Print();  
        }
    }
}

Screenshot after printing to XPS:

Print PDF pages to booklet in C#