We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Printing the PowerPoint presentation with Essential Presentation library

Platform: ASP.NET Web Forms |
Control: Presentation

You can print the presentation document by converting the PowerPoint Presentation slides to images. The System.Drawing.Printing. PrintDocument class can be used to print the converted images by the default printer or to any of the available printer with customized settings.


The following code example demonstrates how to convert the slides of a PowerPoint presentation to images.


//Opens a PowerPoint presentation
IPresentation presentation = Presentation.Open("Sample.pptx");
//Converts the slides to images
Image[] images = presentation.RenderAsImages(Syncfusion.Drawing.ImageType.Bitmap);
//Closes the PowerPoint presentation


The following code example demonstrates how to print the converted images.


//Initializes the start and end page for printing
int startPageIndex = 1;
int endPageIndex = images.Length;
//Creates new PrintDialog instance.
System.Windows.Forms.PrintDialog printDialog = new System.Windows.Forms.PrintDialog();
//Sets new PrintDocument instance to print dialog.
printDialog.Document = new PrintDocument();
//Enables the print current page option.
printDialog.AllowCurrentPage = true;
//Enables the print selected pages option.
printDialog.AllowSomePages = true;
//Sets the start and end page index
printDialog.PrinterSettings.FromPage = 1;
printDialog.PrinterSettings.ToPage = images.Length;
//Opens the print dialog box.
if (printDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
//Checks whether the selected page range is valid or not
if (printDialog.PrinterSettings.FromPage > 0 && printDialog.PrinterSettings.ToPage <= images.Length)
//Updates the start page of the document to print.
startPageIndex = printDialog.PrinterSettings.FromPage - 1;
//Updates the end page of the document to print.
endPageIndex = printDialog.PrinterSettings.ToPage;
//Hooks the PrintPage event to handle be drawing pages for printing.
printDialog.Document.PrintPage += new PrintPageEventHandler(PrintPageMethod);
//Prints the document.
private void PrintPageMethod(object sender, PrintPageEventArgs e)
//Gets the print start page width.
int currentPageWidth = images[startPageIndex].Width;
//Gets the print start page height.
int currentPageHeight = images[startPageIndex].Height;
//Gets the visible bounds width for print.
int visibleClipBoundsWidth = (int)e.Graphics.VisibleClipBounds.Width;
//Gets the visible bounds height for print.
int visibleClipBoundsHeight = (int)e.Graphics.VisibleClipBounds.Height;
//Checks whether the page layout is landscape or portrait.
if (currentPageWidth > currentPageHeight)
//Translates the position.
e.Graphics.TranslateTransform(0, visibleClipBoundsHeight);
//Rotates the object at 270 degrees
//Draws the current page image.
e.Graphics.DrawImage(images[startPageIndex], new System.Drawing.Rectangle(0, 0, currentPageWidth, currentPageHeight));
//Draws the current page image.
e.Graphics.DrawImage(images[startPageIndex], new System.Drawing.Rectangle(0, 0, visibleClipBoundsWidth, visibleClipBoundsHeight));
//Disposes the current page image after drawing.
//Increments the start page index.
//Updates whether the document contains more pages to print or not.
if (startPageIndex < endPageIndex)
e.HasMorePages = true;
startPageIndex = 0;


You can find the complete sample here.

2X faster development

The ultimate ASP.NET Web Forms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile