Related blog post: Convert PowerPoint Presentations to PDF using C#
Last active
November 27, 2021 07:57
-
-
Save GroupDocsGists/3b2358dd1dcdf2281bd21c0f01ceef0c to your computer and use it in GitHub Desktop.
How to Convert PowerPoint Presentation to PDF using C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Convert few consecutive PPT slides to PDF using C# | |
using (Converter converter = new Converter("path/presentation.pptx")) | |
{ | |
PdfConvertOptions options = new PdfConvertOptions | |
{ | |
PageNumber = 2, | |
PagesCount = 3 | |
}; | |
converter.Convert("path/converted-presentation.pdf", options); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Convert whole PPT to PDF using C# | |
using (Converter converter = new Converter("path/presentation.pptx")) | |
{ | |
converter.Convert("path/converted-presentation.pdf", new PdfConvertOptions()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Convert only specific PPT slides to PDF using C# | |
using (Converter converter = new Converter("path/presentation.pptx")) | |
{ | |
PdfConvertOptions options = new PdfConvertOptions | |
{ | |
Pages = new List<int>{ 1, 3 } | |
}; | |
converter.Convert("path/converted-presentation.pdf", options); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// List possible conversions of PPT using .NET API | |
string sourceFile = "path/presentation.pptx"; | |
using (Converter converter = new Converter(sourceFile)) | |
{ | |
PossibleConversions conversions = converter.GetPossibleConversions(); | |
Console.WriteLine("{0} is of type {1} and could be converted to:", sourceFile, conversions.Source.Extension); | |
foreach (var conversion in conversions.All) | |
{ | |
Console.WriteLine("\t {0} as {1} conversion.", conversion.Format, conversion.IsPrimary?"primary": "secondary"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Conversion of presentations to PDF with advanced options using C# | |
using (Converter converter = new Converter("path/presentation.pptx")) | |
{ | |
PdfConvertOptions options = new PdfConvertOptions | |
{ | |
PageNumber = 2, | |
PagesCount = 1, | |
Rotate = Rotation.On180, | |
Dpi = 300, | |
Width = 1024, | |
Height = 768 | |
}; | |
converter.Convert("path/converted-presentation.pdf", options); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Apply watermark to presentation slides while converting it to PDF using C# | |
using (Converter converter = new Converter("path/presentation.pptx")) | |
{ | |
PdfConvertOptions options = new PdfConvertOptions | |
{ | |
Watermark = new WatermarkTextOptions("Watermark") | |
{ | |
Color = Color.Blue, | |
Width = 100, | |
Height = 100, | |
Background = true, | |
RotationAngle = -45, | |
Transparency = 0.5 | |
} | |
}; | |
converter.Convert("path/converted-presentation.pdf", options); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment