Print a PowerPoint document

Spire.Presentation for .NET, a reliable .NET PPT component, enables you to generate, read, edit, convert even print your PPT documents without installing Microsoft PowerPoint on your machine. Using Spire.Presentation for .NET, you can use the presentation.Print() method to print your PPT documents in a fast speed.The following article will introduce a detail method to print a PPT document with C#, VB via Spire.Presentation for .NET.

Download and install Spire.Presentation for .NET and use below code to experience this method to print PPT document.

The main steps of method are:

Step 1: Create a PPT document.

Presentation presentation = new Presentation();

Step 2: Append new shape and paragraph to add the text.

IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 150, 600, 250));
shape.TextFrame.Paragraphs.Append(new TextParagraph());

Step 3: Set the background to DarkSeaGreen.

presentation.Slides[0].SlideBackground.Type = BackgroundType.Custom;
presentation.Slides[0].SlideBackground.Fill.FillType = FillFormatType.Solid;
presentation.Slides[0].SlideBackground.Fill.SolidColor.Color = Color.DarkSeaGreen;

Step 4: Create a printerSettings and print the PPT.

PrinterSettings printerSettings = new PrinterSettings();
presentation.Print(printerSettings);

Suppose you've succeeded use the method, the printer icon would appear in the lower right corner ofscreen. such as: Print a PPT document

If you couldn't successfully use the Spire.presentation, please refer the Spire.Presentation Quick Start which can guide you quickly use the Spire.presentation.

The full code:

[C#]
using System.Drawing;
using System.Drawing.Printing;
using Spire.Presentation;
using Spire.Presentation.Drawing;

namespace PrintPPT
{
    class Program
    {
        static void Main(string[] args)
        {            
            //create PPT document
            Presentation presentation = new Presentation();

            //append new shape
            IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 150, 600, 250));
            shape.ShapeStyle.LineColor.Color = Color.DarkSeaGreen;
            shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None;

            //add text to shape
            shape.AppendTextFrame("The sample demonstrates how to Print PPT file.");

            //add new paragraph
            shape.TextFrame.Paragraphs.Append(new TextParagraph());

            //add text to paragraph            
            shape.TextFrame.Paragraphs[1].TextRanges.Append(new TextRange("As an independent Office .NET component, Spire.Office doesn't need Microsoft Office to be installed on System. In addition, it is a better alternative to MS Office Automation in terms of security, stability, scalability, speed, price and features."));

            //set the Font
            foreach (TextParagraph para in shape.TextFrame.Paragraphs)
            {
                para.TextRanges[0].LatinFont = new TextFont("Arial Rounded MT Bold");
                para.TextRanges[0].Fill.FillType = FillFormatType.Solid;
                para.TextRanges[0].Fill.SolidColor.Color = Color.Black;
                para.Alignment = TextAlignmentType.Left;
                para.Indent = 35;
            }

            //set the background to DarkSeaGreen            
            presentation.Slides[0].SlideBackground.Type = BackgroundType.Custom;
            presentation.Slides[0].SlideBackground.Fill.FillType = FillFormatType.Solid;
            presentation.Slides[0].SlideBackground.Fill.SolidColor.Color = Color.DarkSeaGreen;

            //print
            PrinterSettings printerSettings = new PrinterSettings();
            presentation.Print(printerSettings);            
        }
    }
}
[VB.NET]
Imports System.Drawing
Imports System.Drawing.Printing
Imports Spire.Presentation
Imports Spire.Presentation.Drawing

Namespace PrintPPT
	Class Program
		Private Shared Sub Main(args As String())
			'create PPT document
			Dim presentation As New Presentation()

			'append new shape
			Dim shape As IAutoShape = presentation.Slides(0).Shapes.AppendShape(ShapeType.Rectangle, New RectangleF(50, 150, 600, 250))
			shape.ShapeStyle.LineColor.Color = Color.DarkSeaGreen
			shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None

			'add text to shape
			shape.AppendTextFrame("The sample demonstrates how to Print PPT file.")

			'add new paragraph
			shape.TextFrame.Paragraphs.Append(New TextParagraph())

			'add text to paragraph            
			shape.TextFrame.Paragraphs(1).TextRanges.Append(New TextRange("As an independent Office .NET component, Spire.Office doesn't need Microsoft Office to be installed on System. In addition, it is a better alternative to MS Office Automation in terms of security, stability, scalability, speed, price and features."))

			'set the Font
			For Each para As TextParagraph In shape.TextFrame.Paragraphs
				para.TextRanges(0).LatinFont = New TextFont("Arial Rounded MT Bold")
				para.TextRanges(0).Fill.FillType = FillFormatType.Solid
				para.TextRanges(0).Fill.SolidColor.Color = Color.Black
				para.Alignment = TextAlignmentType.Left
				para.Indent = 35
			Next

			'set the background to DarkSeaGreen            
			presentation.Slides(0).SlideBackground.Type = BackgroundType.[Custom]
			presentation.Slides(0).SlideBackground.Fill.FillType = FillFormatType.Solid
			presentation.Slides(0).SlideBackground.Fill.SolidColor.Color = Color.DarkSeaGreen

			'print
			Dim printerSettings As New PrinterSettings()
			presentation.Print(printerSettings)
		End Sub
	End Class
End Namespace