Use PrintDocument object to print a PowerPoint document

Spire.Presentation has a powerful function to print PowerPoint document. From Spire.Presentation v 2.8.59, it supports to use the PrintDocument object to print the presentation slides. This example shows how to print presentation slides using C# via the following print methods:

  • Print PowerPoint document to default printer.
  • Print PowerPoint document to virtual printer.
  • Print some pages from the PowerPoint document and set the document name, number of copies while printing the presentation slides.

Print presentation slides to default printer and print all the pages on the PowerPoint document.

using Spire.Presentation;
using System.Drawing.Printing;
namespace PrintPPT
{

    class Program
    {

        static void Main(string[] args)
        {
            Presentation ppt = new Presentation();
            ppt.LoadFromFile("Sample.pptx");

            PresentationPrintDocument document = new PresentationPrintDocument(ppt);
            document.PrintController = new StandardPrintController();

            ppt.Print(document);


        }
    }
}

Print PowerPoint document to virtual printer (Microsoft XPS Document Writer).

using Spire.Presentation;
namespace PrintPPT
{

    class Program
    {

        static void Main(string[] args)
        {
            Presentation ppt = new Presentation();
            ppt.LoadFromFile("Sample.pptx");

            PresentationPrintDocument document = new PresentationPrintDocument(ppt);
            document.PrinterSettings.PrinterName = "Microsoft XPS Document Writer";

            ppt.Print(document);


        }
    }
}

Print some pages from the PowerPoint document and set the document name, number of copies while printing the presentation slides.

using Spire.Presentation;
using System.Drawing.Printing;
namespace PrintPPT
{

    class Program
    {

        static void Main(string[] args)
        {
            Presentation ppt = new Presentation();
            ppt.LoadFromFile("Sample.pptx");

            PresentationPrintDocument document = new PresentationPrintDocument(ppt);

            //Set the document name to display while printing the document  
            document.DocumentName = "Print PowerPoint";

            //Choose to print some pages from the PowerPoint document
            document.PrinterSettings.PrintRange = PrintRange.SomePages;
            document.PrinterSettings.FromPage = 1;
            document.PrinterSettings.ToPage = 2;

            //Set the number of copies of the document to print
            document.PrinterSettings.Copies = 2;

            ppt.Print(document);


        }
    }
}