biopdf logo

Print PPTX file to PDF from C#

This is a short example of how to print a Microsoft PowerPoint pptx file to PDF from a c# program. You can easily modify the example to convert other types of documents such as Word or Excel documents.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
// Add the PDF Writer API
using bioPDF.PdfWriter;

namespace PrintPptx
{
    class Program
    {
        static void Main()
        {
            // Get the name of the printer
            string printerName = PdfUtil.DefaultPrinterName;

            // Set printer settings for next print job
            // More setttings are available at http://www.biopdf.com/guide/settings.php
            PdfSettings settings = new PdfSettings();
            settings.PrinterName = printerName;
            settings.SetValue("Output", @"C:\Temp\test.pdf");
            settings.SetValue("ShowSettings", "never");
            settings.SetValue("ShowSaveAs", "never");
            settings.SetValue("ShowPDF", "yes");
            settings.SetValue("ConfirmOverwrite", "no");
            settings.SetValue("RememberLastFileName", "no");
            settings.SetValue("RememberLastFolderName", "no");
            settings.SetValue("SuppressErrors", "yes");
            settings.WriteSettings(PdfSettingsFileType.RunOnce);

            // Printe the pptx file. This requires that you have Microsoft Powerpoint installed
            PdfUtil.PrintFile(@"C:\Temp\test.pptx", printerName);
        }
    }
}

Example source files are included in the zip file that can be downloaded here.

Print PPTX from C#.zip  

 
McAfee SiteAdvisor Norton Safe Web