Introduction
The PresentationToPngConverter class in Slidize.Plugins allows you to convert PowerPoint and OpenDocument presentations into PNG images, where each slide is rendered as a high-quality image. PNG images are ideal when you need lossless image quality for web use, document embedding, or other purposes where preserving the clarity of the original slide is important.
Here we will explore how to use the PresentationToPngConverter class with examples and cover various customization options using the ImageConverterOptions class.
Basic PowerPoint to PNG Conversion
This basic example demonstrates how to convert a PowerPoint presentation into PNG images, with each slide saved as a separate image.
using Slidize;
PresentationToPngConverter.Process("presentation.pptx", "image.png");
In this example, the Process method takes the input PowerPoint file (presentation.pptx) and converts each slide into a PNG image.
Customize Image Dimensions
If you need to generate PNG images with specific dimensions, you can set custom ImageWidth and ImageHeight properties in the ImageConverterOptions class. This is useful for creating images that fit a predefined size requirement.
using Slidize;
var options = new ImageConverterOptions
{
ImageWidth = 1024,
ImageHeight = 768
};
PresentationToPngConverter.Process("presentation.pptx", "image.png", options);
Scale Images
You can scale the images up or down by adjusting the ImageScale property in the ImageConverterOptions class. This allows you to control the size of the output images relative to the original slide size.
using Slidize;
var options = new ImageConverterOptions
{
ImageScale = 2.0f
};
PresentationToPngConverter.Process("presentation.pptx", "image.png", options);
In this example, the ImageScale is set to 2.0f, meaning the output images will be twice the size of the original slide dimensions.
Set a Default Regular Font
The DefaultRegularFont property in the ImageConverterOptions class allows you to specify a default font to use when converting PowerPoint and OpenDocument slides into PNG images, especially in cases where the original fonts used in the presentation are missing or not available on the system where the conversion takes place. This feature ensures consistent text rendering even when certain fonts are not installed on the machine performing the conversion.
using Slidize;
var options = new ImageConverterOptions
{
DefaultRegularFont = "Arial"
};
PresentationToPngConverter.Process("presentation.pptx", "image.png", options);
In this example, if the original fonts used in the presentation are missing or unsupported on the system performing the conversion, the converter will use "Arial" as the fallback font. This ensures that the text is displayed consistently across all slides.
Include Speaker Notes in the Output
The SlidesViewOptions property is useful when you need to include additional slide information like notes or feedback comments as part of the image, enhancing the context or meaning of the slides. The following example shows how to use the SlidesViewOptions property to include speaker notes beneath each slide in the resulting PNG images.
using Slidize;
var options = new ImageConverterOptions
{
SlidesViewOptions = new NotesCommentsViewOptions
{
NotesPosition = NotesPositions.BottomFull
}
};
PresentationToPngConverter.Process("presentation.pptx", "image.png", options);
Include Comments in the Output
You can also include comments, which are often used in presentations for collaboration or feedback. The following example demonstrates how to include comments in the output, positioned on the right side of the slide.
using Slidize;
var options = new ImageConverterOptions
{
SlidesViewOptions = new NotesCommentsViewOptions
{
CommentsPosition = CommentsPositions.Right
}
};
PresentationToPngConverter.Process("presentation.pptx", "image.png", options);
In this example, the CommentsPosition is set to Right, ensuring that the comments appear alongside each slide in the generated PNG images, placing the comments to the right of the slide content.