Table of Contents

Introduction

The PresentationToPdfConverter class in the Slidize.Plugins library provides a powerful and flexible way to convert Microsoft PowerPoint and OpenDocument presentations into PDF format. This conversion is often needed when sharing static copies of presentations, archiving, or distributing slides in a universally accepted format like PDF. The PresentationToPdfConverter class offers a wide range of options for customizing the output, such as setting compliance levels, embedding fonts, including hidden slides, and controlling the appearance of notes and comments.

Here we'll explore the various features of the PresentationToPdfConverter class, providing detailed examples using C#.

Basic PowerPoint to PDF Conversion

The simplest use case for the PresentationToPdfConverter class is converting a PowerPoint presentation directly into a PDF. In this example, we will convert a presentation without any additional customization.

using Slidize;

PresentationToPdfConverter.Process("presentation.pptx", "presentation.pdf");

In this example, the Process method is used to convert the PowerPoint file (presentation.pptx) to PDF format (presentation.pdf). This basic approach is suitable when you do not need to customize the output.

Custom PDF Conversion with Compliance Level

When converting to PDF, you might need to ensure that the output conforms to specific PDF standards, such as PDF/A, which is commonly required for long-term archiving. In this example, we will set the compliance level to PDF/A-1b.

using Slidize;

var options = new PdfConverterOptions
{
    ComplianceLevel = PdfComplianceLevel.PdfA1b
};

PresentationToPdfConverter.Process("presentation.pptx", "presentation.pdf", options);

In this example, we use the PdfConverterOptions class to specify that the output should conform to the PDF/A-1b standard. This ensures that the resulting PDF is suitable for archiving and compliant with specific regulatory requirements.

Embed Fonts in the PDF

By default, Slidize.Plugins does not embed all fonts used in the presentation into the resulting PDF. However, you can customize the export options to embed fonts, ensuring that the appearance of the text in the PDF remains consistent across different devices. This is particularly useful when sharing PDFs with users who may not have the same fonts installed.

using Slidize;

var options = new PdfConverterOptions
{
    EmbedFullFonts = true
};

PresentationToPdfConverter.Process("presentation.pptx", "presentation.pdf", options);

In this example, we set EmbedFullFonts to true in the PdfConverterOptions to ensure that all fonts used in the presentation are embedded in the resulting PDF, providing consistency in text rendering across different platforms.

Include Hidden Slides

Sometimes, presentations contain hidden slides that are not meant to be shown during the presentation but may still need to be included in the exported PDF. In this example, we enable the inclusion of hidden slides in the conversion process.

using Slidize;

var options = new PdfConverterOptions
{
    ShowHiddenSlides = true
};

PresentationToPdfConverter.Process("presentation.pptx", "presentation.pdf", options);

In this example, we set ShowHiddenSlides to true in the PdfConverterOptions, which ensures that all hidden slides are included in the output PDF.

Export Notes and Comments

In some cases, it is necessary to export the speaker notes and comments along with the slides. The PresentationToPdfConverter class allows you to customize how notes and comments are displayed in the final PDF.

using Slidize;

var options = new PdfConverterOptions
{
    SlidesViewOptions = new NotesCommentsViewOptions
    {
        NotesPosition = NotesPositions.BottomFull,
        CommentsPosition = CommentsPositions.Right
    }
};

PresentationToPdfConverter.Process("presentation.pptx", "presentation.pdf", options);

In this example, we configure the NotesCommentsViewOptions to include the full speaker notes at the bottom of each slide and display the comments on the right. This is useful for distributing PDFs that need to retain additional presentation details.

Adjust JPEG Quality in the PDF

The quality of images within the presentation can have a significant impact on the size of the resulting PDF. If you need to balance image quality and file size, you can adjust the JPEG quality in the PdfConverterOptions.

using Slidize;

var options = new PdfConverterOptions
{
    JpegQuality = 85
};

PresentationToPdfConverter.Process("presentation.pptx", "presentation.pdf", options);

Here, we set the JpegQuality property to 85 to achieve a good balance between image quality and file size in the resulting PDF. The default value is 100, which provides the highest quality but can increase the file size.

Rasterize Unsupported Font Styles

Certain fonts may not support specific styles, such as bold or italic. The PdfConverterOptions class includes a setting that allows you to rasterize such text, which converts it into an image. This can improve the appearance of text when the font does not natively support the style, ensuring it is rendered as intended.

using Slidize;

var options = new PdfConverterOptions
{
    RasterizeUnsupportedFontStyles = true
};

PresentationToPdfConverter.Process("presentation.pptx", "presentation.pdf", options);

By setting RasterizeUnsupportedFontStyles to true, the converter ensures that unsupported font styles like bold or italic are rasterized as images, preserving the intended visual appearance.

Best Image Compression Ratio

When converting presentations that contain a lot of images, controlling the compression ratio can help optimize the output file size. The BestImagesCompressionRatio option allows the converter to automatically select the most efficient compression algorithm for each image.

using Slidize;

var options = new PdfConverterOptions
{
    BestImagesCompressionRatio = true
};

PresentationToPdfConverter.Process("presentation.pptx", "presentation.pdf", options);

Setting BestImagesCompressionRatio to true enables the converter to choose the most appropriate image compression method for each image, which can significantly reduce the file size without sacrificing much image quality.

Flat Text Compression for Improved File Size

The UseFlatTextCompression option controls whether flat compression is applied to the text within the presentation. This setting can reduce the size of the PDF by compressing text more efficiently.

using Slidize;

var options = new PdfConverterOptions
{
    UseFlatTextCompression = true
};

PresentationToPdfConverter.Process("presentation.pptx", "presentation.pdf", options);

With UseFlatTextCompression set to true, the PDF converter compresses text more aggressively, which can help in reducing the overall file size, especially for text-heavy presentations.

Control Image Resolution

For presentations containing high-resolution images, it may be beneficial to control the resolution of the images in the output PDF. You can adjust the SufficientResolution property to balance between image quality and file size.

using Slidize;

var options = new PdfConverterOptions
{
    SufficientResolution = 150f
};

PresentationToPdfConverter.Process("presentation.pptx", "presentation.pdf", options);

In this example, the SufficientResolution property is set to 150f to ensure the images are exported at a reasonable quality without excessively increasing the PDF file size. The default resolution is 96 DPI, and increasing this value will improve image quality at the cost of a larger file.

Control Embedded OLE Data in PDF

Some presentations contain OLE (Object Linking and Embedding) objects, such as Excel charts or other embedded documents. By setting the IncludeOleData option, you can choose whether or not to include this data in the PDF.

using Slidize;

var options = new PdfConverterOptions
{
    IncludeOleData = true
};

PresentationToPdfConverter.Process("presentation.pptx", "presentation.pdf", options);

In this example, setting IncludeOleData to true ensures that any OLE objects embedded within the presentation are retained in the resulting PDF.