Convert PowerPoint to PDF using Syncfusion PowerPoint library
9 Sep 202424 minutes to read
Syncfusion PowerPoint library (Presentation) allows you to convert PowerPoint Presentation document to PDF within a few lines of code in .NET applications and also it does not require Adobe and Microsoft PowerPoint application to be installed in the machine. Using this, you can create an input PowerPoint Presentation document from scratch or load an existing PowerPoint Presentation document and then easily convert to PDF.
The Syncfusion PowerPoint to PDF converter offers high versatility and seamless performance across various .NET platforms, including Windows Forms, WPF, ASP.NET, ASP.NET MVC, ASP.NET Core, Blazor, Xamarin, WinUI, .NET MAUI. Also, in different environments like Azure, AWS, Google Cloud, Linux, and macOS.
Key Features
- Ability to convert entire PowerPoint Presentation document to PDF.
- Specify the number of slides per PDF page with Handouts option.
- Convert slides with notes pages to PDF.
- Embed fonts in a PowerPoint file into the converted PDF document to avoid font-related issues across different machines and different platforms.
- Convert a PowerPoint document to PDF with the PDF-A1B conformance standards.
- Specify fallback fonts to be used in place of missing fonts.
- Skip or include hidden slides.
- Set the quality of images in the PowerPoint slides to reduce the converted PDF document size.
Assemblies and NuGet packages required
Refer to the following links for assemblies required based on platforms to convert the PowerPoint document to PDF.
To quickly start converting a PowerPoint Presentation to a PDF using .NET PowerPoint library, please check out this video:
Convert PowerPoint to PDF
The following namespaces are required to compile the code:
using Syncfusion.Pdf;
using Syncfusion.Presentation;
using Syncfusion.PresentationRenderer;
using Syncfusion.OfficeChartToImageConverter;
using Syncfusion.Presentation;
using Syncfusion.PresentationToPdfConverter;
using Syncfusion.Pdf;
Imports Syncfusion.OfficeChartToImageConverter
Imports Syncfusion.Presentation
Imports Syncfusion.PresentationToPdfConverter
Imports Syncfusion.Pdf
The following code example illustrates how to convert a PowerPoint document into PDF document.
//Load the PowerPoint presentation into stream.
using (FileStream fileStreamInput = new FileStream("Template.pptx", FileMode.Open, FileAccess.Read))
{
//Open the existing PowerPoint presentation with loaded stream.
using (IPresentation pptxDoc = Presentation.Open(fileStreamInput))
{
//Create the MemoryStream to save the converted PDF.
using (MemoryStream pdfStream = new MemoryStream())
{
//Convert the PowerPoint document to PDF document.
using (PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc))
{
//Save the converted PDF document to MemoryStream.
pdfDocument.Save(pdfStream);
pdfStream.Position = 0;
}
//Create the output PDF file stream
using (FileStream fileStreamOutput = File.Create("Output.pdf"))
{
//Copy the converted PDF stream into created output PDF stream
pdfStream.CopyTo(fileStreamOutput);
}
}
}
}
//Opens a PowerPoint Presentation
IPresentation pptxDoc = Presentation.Open("Sample.pptx");
//Creates an instance of ChartToImageConverter and assigns it to ChartToImageConverter property of Presentation
pptxDoc.ChartToImageConverter = new ChartToImageConverter();
//Converts the PowerPoint Presentation into PDF document
PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc);
//Saves the PDF document
pdfDocument.Save("Sample.pdf");
//Closes the PDF document
pdfDocument.Close(true);
//Closes the Presentation
pptxDoc.Close();
'Opens a PowerPoint Presentation
Dim pptxDoc As IPresentation = Presentation.Open("Sample.pptx")
'Creates an instance of ChartToImageConverter and assigns it to ChartToImageConverter property of Presentation
pptxDoc.ChartToImageConverter = New ChartToImageConverter()
'Converts the PowerPoint Presentation into PDF document
Dim pdfDocument As PdfDocument = PresentationToPdfConverter.Convert(pptxDoc)
'Saves the PDF document
pdfDocument.Save("Sample.pdf")
'Closes the PDF document
pdfDocument.Close(True)
'Closes the Presentation
pptxDoc.Close()
You can download a complete working sample from GitHub.
NOTE
- Creating an instance of ChartToImageConverter class is mandatory to convert the charts present in the Presentation to PDF. Otherwise, the charts are not exported to the converted PDF
- The assembly “Syncfusion.SfChart.WPF” is non compliance with FIPS (Federal Information Processing Standard) algorithm policy.
- In .NET Core targeting applications, metafile images such as EMF and WMF have some limitations. So, those images will not preserve in Presentation document to PDF conversion using Essential Presentation.
NOTE
- To preserve the expected images in the PDF, we suggest you convert the metafile image formats to bitmap image format (JPEG or PNG) and then perform Presentation to PDF conversion.
- Otherwise, you can use the WPF or Windows Forms platform NuGet packages for .NET Core 3.0 or later versions targeting applications from v17.3.0.x and use the same C# tab code examples for it. But in Mac and Linux environment, using the WPF or Windows Forms platform NuGet packages have limitations.
PowerPoint Presentation to PDF conversion in Linux OS
In Linux OS, you can perform the PowerPoint presentation to PDF conversion using .NET Core (Targeting .netcoreapp) application. For further information, click here.
Font substitution
When a font used in a PowerPoint presentation is unavailable in the environment where it is converted to PDF, then the library substitutes the ‘Microsoft Sans Serif’ as a default font for text rendering. This leads to a difference in text layouts of PowerPoint presentation and the converted PDF document. To avoid this, the Essential Presentation library allows you to set an alternate font for the missing font used in the PowerPoint presentation. For further information, click here.
Fallback fonts
During PowerPoint to PDF conversions, if a glyph of the input text is unavailable in the specified font, the text will not be rendered properly. To address this, the Syncfusion PowerPoint (Presentation) library allows users to specify fallback fonts. When a glyph is missing, the library will use one of the fallback fonts to render the text correctly in the output PDF document. For further information, click here.
Show Warning for unsupported elements
The Presentation library shows warning message about the unsupported elements such as Metafile images and charts (supported from .NET Standard 2.0) present in the input PowerPoint presentation, during PowerPoint to PDF conversion. It also allows you to cancel or continue the PowerPoint to PDF conversion, when any unsupported elements is present in the input PowerPoint presentation.
The following code example demonstrates how to cancel or continue the PowerPoint presentation to PDF conversion, when an unsupported elements (Metafile and Chart) are present in the input PowerPoint presentation.
// Open the file as Stream
using (FileStream pptStream = new FileStream("Template.pptx", FileMode.Open, FileAccess.Read))
{
//Open the existing PowerPoint presentation with loaded stream.
using (IPresentation pptxDoc = Presentation.Open(pptStream))
{
//Instantiation of PresentationToPdfConverterSettings
PresentationToPdfConverterSettings settings = new PresentationToPdfConverterSettings();
//Gets all the warnings into the collection
settings.Warning = new DocumentWarning();
//Converts the PowerPoint Presentation into PDF document
using (PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc, settings))
{
//If the PowerPoint to Pdf conversion has been stopped, IsCanceled value will be True, otherwise false
if (!PresentationToPdfConverter.IsCanceled)
{
//Saves the PDF file
using (FileStream outputStream = new FileStream("Output.pdf", FileMode.OpenOrCreate, FileAccess.ReadWrite))
{
pdfDocument.Save(outputStream);
outputStream.Position = 0;
}
}
else
{
Console.WriteLine("PowerPoint to PDF conversion is stopped , please press any key to exit the application");
Console.ReadKey();
}
}
}
}
/// <summary>
/// DocumentWarning class implements the IWarning interface
/// </summary>
/// <seealso cref="IWarning" />
public class DocumentWarning : IWarning
{
/// <summary>
/// Gets the Boolen value whether to continue conversion or not
/// </summary>
/// <param name="warningInfo">Collection of warnings</param>
/// <returns></returns>
public bool ShowWarnings(List<WarningInfo> warningInfo)
{
//By default to perform the PowerPoint to PDF conversion by setting the isContinueConversion as true.
bool isContinueConversion = true;
foreach (WarningInfo warning in warningInfo)
{
//Since there are warnings in the PowerPoint presentation the value of isContinueConversion will be set as false.
isContinueConversion = false;
//Print the description of the Warining
Console.WriteLine(warning.Description);
if (warning.Description.Contains("Metafile") || warning.Description.Contains("Chart"))
{
Console.WriteLine("Type [Y] if you want Do you want to continue Presentation to Pdf conversion or Type [N] to cancel the conversion");
String confrimation = Console.ReadLine();
//Based on warning.WarningType enumeration, you can do your manipulation.
//Skips the PowerPoint to Pdf conversion by setting isContinueConversion value as false.
//Continue the PowerPoint to PDF conversion by setting the isContinueConversion as true.
if (confrimation.ToLower().Equals("y"))
isContinueConversion = true;
else
isContinueConversion = false;
}
}
return isContinueConversion;
}
}
//Essential Presentation library supports Show warning for unsupported elements feature in C# [Cross-platform], Blazor server-side application and Xamarin platforms alone.
//Essential Presentation supports library Show warning for unsupported elements feature in C# [Cross-platform], Blazor server-side application and Xamarin platforms alone.
You can download a complete working sample from GitHub.
Handouts
The Presentation library allows you to convert a PowerPoint presentation to PDF document with Handouts option. Thus, the library allows selecting the number of slides to be included per PDF page. This helps converting multiple PowerPoint slides within a single PDF page.
The following code sample demonstrates how to convert a PowerPoint presentation to PDF document with Handouts property.
//Load the PowerPoint presentation to convert.
IPresentation pptxDoc = Presentation.Open("Sample.pptx");
//Enable the handouts and number of pages per slide options in converter settings.
PresentationToPdfConverterSettings pdfConverterSettings = new PresentationToPdfConverterSettings();
pdfConverterSettings.PublishOptions = PublishOptions.Handouts;
pdfConverterSettings.SlidesPerPage = SlidesPerPage.Nine;
//Convert the documents by passing the PDF conversion settings as parameter.
PdfDocument pdfDoc = PresentationToPdfConverter.Convert(pptxDoc, pdfConverterSettings);
//Save the converted PDF document.
pdfDoc.Save("Sample.pdf");
//Close the presentation instance
pptxDoc.Close();
//Close the PDF instance
pdfDoc.Close();
'Load the PowerPoint presentation to convert.
Dim pptxDoc As IPresentation = Presentation.Open("Sample.pptx")
'Enable the handouts and number of pages per slide options in converter settings.
Dim pdfConverterSettings As PresentationToPdfConverterSettings = new PresentationToPdfConverterSettings()
pdfConverterSettings.PublishOptions = PublishOptions.Handouts
pdfConverterSettings.SlidesPerPage = SlidesPerPage.Nine
'Convert the documents by passing the PDF conversion settings as parameter.
Dim pdfDoc As PdfDocument = PresentationToPdfConverter.Convert(pptxDoc, pdfConverterSettings)
'Save the converted PDF document.
pdfDoc.Save("Sample.pdf")
'Close the presentation instance
pptxDoc.Close()
'Close the PDF instance
pdfDoc.Close()
You can download a complete working sample from GitHub.
Notes pages
The Presentation library allows you to convert a PowerPoint presentation to PDF document with ‘notes pages’ option, which will includes the notes content while PDF conversion.
The following code sample demonstrates how to convert a PowerPoint presentation to PDF with ‘notes pages’.
//Load the PowerPoint presentation to convert.
IPresentation pptxDoc = Presentation.Open("Sample.pptx");
//Enable the include hidden slides option in converter settings.
PresentationToPdfConverterSettings pdfConverterSettings = new PresentationToPdfConverterSettings();
pdfConverterSettings.PublishOptions = PublishOptions.NotesPages;
//Convert the documents by passing the settings as parameter.
PdfDocument pdfDoc = PresentationToPdfConverter.Convert(pptxDoc, pdfConverterSettings);
//Save the converted PDF file.
pdfDoc.Save("Sample.pdf");
//Close the presentation instance
pptxDoc.Close();
//Close the PDF instance
pdfDoc.Close();
'Load the PowerPoint presentation to convert.
Dim pptxDoc As IPresentation = Presentation.Open("Sample.pptx")
'Enable the include hidden slides option in converter settings.
Dim pdfConverterSettings As PresentationToPdfConverterSettings pdfConverterSettings = new PresentationToPdfConverterSettings()
pdfConverterSettings.PublishOptions = PublishOptions.NotesPages
'Convert the documents by passing the settings as parameter.
Dim pdfDoc As PdfDocument = PresentationToPdfConverter.Convert(pptxDoc, pdfConverterSettings)
'Save the converted PDF file.
pdfDoc.Save("Sample.pdf")
'Close the presentation instance
pptxDoc.Close()
'Close the PDF instance
pdfDoc.Close()
You can download a complete working sample from GitHub.
Include hidden slides
The PowerPoint presentation supports hiding the slides in a presentation document. The hidden slides will not be included in the converted PDF document, by default. The Presentation library provides support to include or exclude the hidden slides while converting a PowerPoint presentation to PDF document.
The following code sample demonstrates how to include the hidden slides while converting a PowerPoint presentation to PDF document.
//Load the PowerPoint presentation to convert.
IPresentation pptxDoc = Presentation.Open("Sample.pptx");
//Enable or disable including the hidden slides option in converter settings.
PresentationToPdfConverterSettings pdfConverterSettings = new PresentationToPdfConverterSettings();
pdfConverterSettings.ShowHiddenSlides = true;
//Convert the documents by passing the settings as parameter.
PdfDocument pdfDoc = PresentationToPdfConverter.Convert(pptxDoc, pdfConverterSettings);
//Save the converted PDF file.
pdfDoc.Save("Sample.pdf");
//Close the presentation instance
pptxDoc.Close();
//Close the PDF instance
pdfDoc.Close();
'Load the PowerPoint presentation to convert.
Dim pptxDoc As IPresentation = Presentation.Open("Sample.pptx")
'Enable or disable including the hidden slides option in converter settings.
Dim pdfConverterSettings As PresentationToPdfConverterSettings = new PresentationToPdfConverterSettings()
pdfConverterSettings.ShowHiddenSlides = true
'Convert the documents by passing the settings as parameter.
Dim pdfDoc As PdfDocument = PresentationToPdfConverter.Convert(pptxDoc, pdfConverterSettings)
'Save the converted PDF file.
pdfDoc.Save("Sample.pdf")
'Close the presentation instance
pptxDoc.Close()
'Close the PDF instance
pdfDoc.Close()
You can download a complete working sample from GitHub.
Recreate Nested Metafile
This setting allows you to regenerate the nested EMF images in the PowerPoint presentation document during PDF conversion. This property is recommended to resolve the scaling problem of the nested metafile images by regenerating the nested metafile images present in the PowerPoint presentation document.
The following code sample shows how to use this property to regenerate the nested EMF images in the PowerPoint presentation document during PDF conversion.
//Open a PowerPoint Presentation.
using (IPresentation pptxDoc = Presentation.Open("Sample.pptx"))
{
//Create an instance of the ChartToImageConverter and assign it to the ChartToImageConverter property of the Presentation.
pptxDoc.ChartToImageConverter = new ChartToImageConverter();
//Initialize the conversion settings.
PresentationToPdfConverterSettings pdfConverterSettings = new PresentationToPdfConverterSettings();
//Set the RecreateNestedMetafile property to true to recreate the nested metafile automatically.
pdfConverterSettings.RecreateNestedMetafile = true;
//Convert the PowerPoint Presentation into a PDF document.
using (PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc, pdfConverterSettings))
{
//Save a PDF document.
pdfDocument.Save("Sample.pdf");
}
}
'Open a PowerPoint Presentation.
Using pptxDoc As IPresentation = Presentation.Open("Sample.pptx")
'Create an instance of the ChartToImageConverter and assign it to the ChartToImageConverter property of the Presentation.
pptxDoc.ChartToImageConverter = New ChartToImageConverter()
'Initialize the conversion settings.
Dim pdfConverterSettings As PresentationToPdfConverterSettings = New PresentationToPdfConverterSettings()
'Set the RecreateNestedMetafile property to true to recreate the nested metafile automatically.
pdfConverterSettings.RecreateNestedMetafile = True
'Convert the PowerPoint Presentation into a PDF document.
Using pdfDocument As PdfDocument = PresentationToPdfConverter.Convert(pptxDoc, pdfConverterSettings)
'Save a PDF document.
pdfDocument.Save("Sample.pdf")
End Using
End Using
You can download a complete working sample from GitHub.
PDF Conformance
Essential Presentation currently supports following PDF conformances while converting a PowerPoint document to PDF.
- PDF/A-1b conformance
- PDF/X-1a conformance
NOTE
- To know more details about PDF/A standard refer https://en.wikipedia.org/wiki/PDF/A#Description
- To know more details about PDF/X standard refer https://en.wikipedia.org/wiki/PDF/X
The following code sample demonstrates how to set the PDF conformance level while PowerPoint presentation to PDF conversion.
//Load the PowerPoint document
IPresentation pptxDoc = Presentation.Open("Sample.pptx"));
//Initialize the conversion settings
PresentationToPdfConverterSettings pdfConverterSettings = new PresentationToPdfConverterSettings();
//Set the Pdf conformance level to A1B
pdfConverterSettings.PdfConformanceLevel = PdfConformanceLevel.Pdf_A1B;
//Convert the PowerPoint document to PDF
PdfDocument pdfDoc = PresentationToPdfConverter.Convert(pptxDoc,pdfConverterSettings);
//Save the converted PDF file.
pdfDoc.Save("Sample.pdf");
//Close the presentation instance
pptxDoc.Close();
//Close the PDF instance
pdfDoc.Close();
'Load the PowerPoint presentation to convert.
Dim pptxDoc As IPresentation = Presentation.Open("Sample.pptx")
'Enable or disable including the hidden slides option in converter settings.
Dim pdfConverterSettings As PresentationToPdfConverterSettings = new PresentationToPdfConverterSettings()
'Set the Pdf conformance level to A1B
pdfConverterSettings.PdfConformanceLevel = PdfConformanceLevel.Pdf_A1B
'Convert the documents by passing the settings as parameter.
Dim pdfDoc As PdfDocument = PresentationToPdfConverter.Convert(pptxDoc, pdfConverterSettings)
'Save the converted PDF file.
pdfDoc.Save("Sample.pdf")
'Close the presentation instance
pptxDoc.Close()
'Close the PDF instance
pdfDoc.Close()
You can download a complete working sample from GitHub.
Accessible PDF document
This setting allows you to determine whether to preserve structured document tags in the converted PDF document for accessibility (508 or PDF/UA compliance) support. This property will set the title and description for images, diagrams, and other objects in the generated PDF document. This information will be helpful for people with vision or cognitive impairments who may not be able to see or understand the object.
The following code sample shows how to preserve structured document tags in the converted PDF document.
//Load the PowerPoint presentation into a stream.
using (FileStream fileStreamInput = new FileStream("Sample.pptx", FileMode.Open, FileAccess.Read))
{
//Open the existing PowerPoint presentation with the loaded stream.
using (IPresentation pptxDoc = Presentation.Open(fileStreamInput))
{
//Instantiation of the PresentationToPdfConverterSettings.
PresentationToPdfConverterSettings pdfConverterSettings = new PresentationToPdfConverterSettings();
//Enable a flag to preserve structured document tags in the converted PDF document.
pdfConverterSettings.AutoTag = true;
//Convert the PowerPoint document to a PDF document.
using (PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc, pdfConverterSettings))
{
//Save the converted PDF document to the fileStream.
using (FileStream fileStreamOutput = File.Create("Sample.pdf"))
{
pdfDocument.Save(fileStreamOutput);
fileStreamOutput.Position = 0;
}
}
}
}
//Open a PowerPoint Presentation.
using (IPresentation pptxDoc = Presentation.Open("Sample.pptx"))
{
//Create an instance of the ChartToImageConverter and assign it to the ChartToImageConverter property of the Presentation.
pptxDoc.ChartToImageConverter = new ChartToImageConverter();
//Initialize the conversion settings.
PresentationToPdfConverterSettings pdfConverterSettings = new PresentationToPdfConverterSettings();
//Enable a flag to preserve structured document tags in the converted PDF document.
pdfConverterSettings.AutoTag = true;
//Convert the PowerPoint Presentation into a PDF document.
using (PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc, pdfConverterSettings))
{
//Save a PDF document.
pdfDocument.Save("Sample.pdf");
}
}
'Open a PowerPoint Presentation.
Using pptxDoc As IPresentation = Presentation.Open("Sample.pptx")
'Create an instance of the ChartToImageConverter and assign it to the ChartToImageConverter property of the Presentation.
pptxDoc.ChartToImageConverter = New ChartToImageConverter()
'Initialize the conversion settings.
Dim pdfConverterSettings As PresentationToPdfConverterSettings = New PresentationToPdfConverterSettings()
'Enable a flag to preserve structured document tags in the converted PDF document.
pdfConverterSettings.AutoTag = True
'Convert the PowerPoint Presentation into a PDF document.
Using pdfDocument As PdfDocument = PresentationToPdfConverter.Convert(pptxDoc, pdfConverterSettings)
'Save a PDF document.
pdfDocument.Save("Sample.pdf")
End Using
End Using
You can download a complete working sample from GitHub.
Chart quality
The Presentation library provides an option to decide the quality of the charts to optimize the converted PDF document size.
NOTE
- The default ScalingMode for charts is ScalingMode.Normal.
- Setting the Best scaling mode will improve the quality of the converted charts and increase the converted PDF document size.
The following code sample demonstrates how to set the quality of the charts while PowerPoint presentation to PDF conversion.
//Load the PowerPoint presentation to convert.
IPresentation pptxDoc = Presentation.Open("Sample.pptx");
//Create an instance of ChartToImageConverter and assigns it to ChartToImageConverter property of Presentation
pptxDoc.ChartToImageConverter = new ChartToImageConverter();
//Sets the scaling mode of the chart to best.
pptxDoc.ChartToImageConverter.ScalingMode = ScalingMode.Best;
//Convert the documents by passing the PDF conversion settings as parameter.
PdfDocument pdfDoc = PresentationToPdfConverter.Convert(pptxDoc);
//Save the converted PDF document.
pdfDoc.Save("Sample.pdf");
//Close the presentation instance
pptxDoc.Close();
//Close the PDF instance
pdfDoc.Close();
'Load the PowerPoint presentation to convert.
Dim pptxDoc As IPresentation = Presentation.Open("Sample.pptx")
'Create an instance of ChartToImageConverter and assigns it to ChartToImageConverter property of Presentation
pptxDoc.ChartToImageConverter = new ChartToImageConverter()
'Sets the scaling mode of the chart to best.
pptxDoc.ChartToImageConverter.ScalingMode = ScalingMode.Best
'Convert the documents by passing the PDF conversion settings as parameter.
Dim pdfDoc As PdfDocument = PresentationToPdfConverter.Convert(pptxDoc)
'Save the converted PDF document.
pdfDoc.Save("Sample.pdf")
'Close the presentation instance
pptxDoc.Close()
'Close the PDF instance
pdfDoc.Close()
You can download a complete working sample from GitHub.
Optimizing the converted PDF document size
Optimizing the identical images
The presentation library allows you to optimize the memory usage for the duplicate images while converting the PowerPoint presentation to PDF document to reduce the document size.
The following code sample demonstrates how to optimize the duplicate images while converting a PowerPoint presentation to PDF document.
//Load the PowerPoint presentation to convert.
IPresentation pptxDoc = Presentation.Open("Sample.pptx");
//Enable the include hidden slides option in converter settings.
PresentationToPdfConverterSettings pdfConverterSettings = new PresentationToPdfConverterSettings();
//Set the flag to optimize the identical images
pdfConverterSettings.OptimizeIdenticalImages = true;
//Convert the documents by passing the settings as parameter.
PdfDocument pdfDoc = PresentationToPdfConverter.Convert(pptxDoc, pdfConverterSettings);
//Save the converted PDF file.
pdfDoc.Save("Sample.pdf");
//Close the presentation instance
pptxDoc.Close();
//Close the PDF instance
pdfDoc.Close();
'Load the PowerPoint presentation to convert.
Dim pptxDoc As IPresentation = Presentation.Open("Sample.pptx")
'Enable the include hidden slides option in converter settings.
Dim pdfConverterSettings As PresentationToPdfConverterSettings = new PresentationToPdfConverterSettings()
'Set the flag to optimize the identical images
pdfConverterSettings.OptimizeIdenticalImages = true
'Convert the documents by passing the settings as parameter.
Dim pdfDoc As PdfDocument = PresentationToPdfConverter.Convert(pptxDoc, pdfConverterSettings)
Save the converted PDF file.
pdfDoc.Save("Sample.pdf")
Close the presentation instance
pptxDoc.Close()
Close the PDF instance
pdfDoc.Close()
You can download a complete working sample from GitHub.
Optimizing the image quality and resolution
You may have high resolution images in the PowerPoint slides which will impact the size of the converted PDF document. The Presentation library allows you to optimize the document size, by adjusting the quality and resolution of the images while converting the PowerPoint presentation to PDF document.
The following code sample demonstrates how to optimize the image quality and resolution while converting a PowerPoint presentation to PDF document.
//Load the PowerPoint presentation to convert.
IPresentation pptxDoc = Presentation.Open("Sample.pptx");
//Enable the include hidden slides option in converter settings.
PresentationToPdfConverterSettings pdfConverterSettings = new PresentationToPdfConverterSettings();
//Set the image resolution
pdfConverterSettings.ImageResolution = 100;
//Set the image quality
pdfConverterSettings.ImageQuality = 100;
//Convert the documents by passing the settings as parameter.
PdfDocument pdfDoc = PresentationToPdfConverter.Convert(pptxDoc, pdfConverterSettings);
//Save the converted PDF file.
pdfDoc.Save("Sample.pdf");
//Close the presentation instance
pptxDoc.Close();
//Close the PDF instance
pdfDoc.Close();
'Load the PowerPoint presentation to convert.
Dim pptxDoc As IPresentation = Presentation.Open("Sample.pptx")
'Enable the include hidden slides option in converter settings.
Dim pdfConverterSettings As PresentationToPdfConverterSettings = new PresentationToPdfConverterSettings()
'Set the image resolution
pdfConverterSettings.ImageResolution = 100
'Set the image quality
pdfConverterSettings.ImageQuality = 100
'Convert the documents by passing the settings as parameter.
Dim pdfDoc As PdfDocument = PresentationToPdfConverter.Convert(pptxDoc, pdfConverterSettings)
'Save the converted PDF file.
pdfDoc.Save("Sample.pdf")
'Close the presentation instance
pptxDoc.Close()
'Close the PDF instance
pdfDoc.Close()
You can download a complete working sample from GitHub.