Print Presentation
Aspose.Slides for .NET provides 4 overloaded Print methods that allow you to print presentations. The overloaded methods take different arguments, so you will always find a method that suits your printing needs.
Print to Default Printer
This simple print operation is used to print all the slides in a PowerPoint presentation through a system’s default printer.
- Create an instance of the Presentation class and pass the presentation you want to print.
- Call the Print method (with no parameters).
This C# code shows you how to print a PowerPoint presentation:
// Loads the presentation
Presentation presentation = new Presentation("Print.ppt");
// Calls the print method with no parameters
presentation.Print();
Print to Specific Printer
This operation is used to print all the slides in a PowerPoint presentation through a specific printer.
- Create an instance of the Presentation class and pass the presentation you want to print.
- Call the Print method and pass the printer name as a string.
This C# code shows you how to print a PowerPoint presentation using a specific printer:
try
{
// Loads the presentation
Presentation presentation = new Presentation("Print.ppt");
// Calls the print method with the printer name
presentation.Print("Please set your printer name here");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message + "\nPlease set printer name as string parameter to the Presentation Print method");
}
Set Print Options Dynamically
Using properties from the PrinterSettings class, you can apply parameters that define the printing operation. You can specify how many copies should be printed, whether slides should be printed in landscape or portrait, your preferred margins, etc.
- Create an instance of the Presentation class and pass the presentation you want to print.
- Instantiate the PrinterSettings class.
- Specify your preferred parameters for the printing operation:
- the number of copies
- page orientation
- margin figures, etc.
- Call the
Print
method.
This C# code shows you how to print a PowerPoint presentation with certain print options:
using (Presentation pres = new Presentation())
{
PrinterSettings printerSettings = new PrinterSettings();
printerSettings.Copies = 2;
printerSettings.DefaultPageSettings.Landscape = true;
printerSettings.DefaultPageSettings.Margins.Left = 10;
//...etc
pres.Print(printerSettings);
}