The following example shows the most common use case for converting PowerPoint presentation to PDF. The source PPTX file is loaded from a current folder. The converted file is saved to the same folder.
usingSystem;usingGroupDocs.Conversion.LowCode;// Load license keysvarpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");varprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");// Apply the licenseLicense.Set(publicKey,privateKey);// Create a converter for the PPTX filevarconverter=newPptxToPdfConverter("presentation.pptx");// Convert PPTX to PDFconverter.Convert("converted.pdf");
ImportsSystemImportsGroupDocs.Conversion.LowCodeModuleProgramSubMain()' Load license keys
DimpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")DimprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")' Apply the license
License.Set(publicKey,privateKey)' Create a converter from file path
DimconverterAsNewPptxToPdfConverter("presentation.pptx")' Convert PPTX to PDF
converter.Convert("converted.pdf")EndSubEndModule
openSystemopenGroupDocs.Conversion.LowCode[<EntryPoint>]letmain_=// Load license keys
letpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")letprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")// Apply the license
License.Set(publicKey,privateKey)// Create a converter from file path
letconverter=newPptxToPdfConverter("presentation.pptx")// Convert PPTX to PDF
converter.Convert("converted.pdf")0
This section covers only the main scenarios. You can also refer to the API references for the PresentationLoadOptions for a complete list of options that you can specify.
Convert Protected PPTX to PDF
The following example shows how to convert protected PPTX file and save it to unprotected PDF file.
In case you do not specify password for protected document PasswordRequiredException is going to be thrown.
usingSystem;usingGroupDocs.Conversion.LowCode;// Load license keysvarpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");varprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");// Apply licenseLicense.Set(publicKey,privateKey);// Provide password through load optionsvarconverter=newPptxToPdfConverter("protected.pptx",options=>{options.Password="12345";});// Convert PPTX to PDFconverter.Convert("unprotected.pdf");
ImportsGroupDocs.Conversion.LowCodeModuleProgramSubMain()' Load license keys
DimpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")DimprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")' Apply license
License.Set(publicKey,privateKey)' Provide password through load options
DimconverterAsNewPptxToPdfConverter("protected.pptx",Sub(options)options.Password="12345"EndSub)' Convert PPTX to PDF
converter.Convert("unprotected.pdf")EndSubEndModule
openSystemopenGroupDocs.Conversion.LowCode[<EntryPoint>]letmain_=// Load license keys
letpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")letprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")// Apply license
License.Set(publicKey,privateKey)// Provide password through load options
letconverter=newPptxToPdfConverter("protected.pptx",funoptions->options.Password<-"12345")// Convert PPTX to PDF
converter.Convert("unprotected.pdf")0
By default hidden slides are not added to the converted PDF document.
The following example shows how to include hidden slides when converting PPTX to PDF using the ShowHiddenSlides property.
usingSystem;usingGroupDocs.Conversion.LowCode;// Load license keysvarpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");varprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");// Apply licenseLicense.Set(publicKey,privateKey);// Show hidden slides through load optionsvarconverter=newPptxToPdfConverter("with-hidden-slides.pptx",options=>{options.ShowHiddenSlides=true;});// Convert PPTX to PDFconverter.Convert("with-hidden-slides.pdf");
ImportsGroupDocs.Conversion.LowCodeModuleProgramSubMain()' Load license keys
DimpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")DimprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")' Apply license
License.Set(publicKey,privateKey)' Show hidden slides through load options
DimconverterAsNewPptxToPdfConverter("with-hidden-slides.pptx",Sub(options)options.ShowHiddenSlides=TrueEndSub)' Convert PPTX to PDF
converter.Convert("with-hidden-slides.pdf")EndSubEndModule
openSystemopenGroupDocs.Conversion.LowCode[<EntryPoint>]letmain_=// Load license keys
letpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")letprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")// Apply license
License.Set(publicKey,privateKey)// Show hidden slides through load options
letconverter=newPptxToPdfConverter("with-hidden-slides.pptx",funoptions->options.ShowHiddenSlides<-true)// Convert PPTX to PDF
converter.Convert("with-hidden-slides.pdf")0
The following example shows how to preserve the document structure when converting PPTX to PDF using the PreserveDocumentStructure property. When this option is enabled, the structure will be preserved for accessible PDF.
usingSystem;usingGroupDocs.Conversion.LowCode;// Load license keysvarpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");varprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");// Apply licenseLicense.Set(publicKey,privateKey);// Preserve document structure through load optionsvarconverter=newPptxToPdfConverter("presentation.pptx",options=>{options.PreserveDocumentStructure=true;});// Convert PPTX to PDFconverter.Convert("accessible.pdf");
ImportsGroupDocs.Conversion.LowCodeModuleProgramSubMain()' Load license keys
DimpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")DimprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")' Apply license
License.Set(publicKey,privateKey)' Preserve document structure through load options
DimconverterAsNewPptxToPdfConverter("presentation.pptx",Sub(options)options.PreserveDocumentStructure=TrueEndSub)' Convert PPTX to PDF
converter.Convert("accessible.pdf")EndSubEndModule
openSystemopenGroupDocs.Conversion.LowCode[<EntryPoint>]letmain_=// Load license keys
letpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")letprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")// Apply license
License.Set(publicKey,privateKey)// Preserve document structure through load options
letconverter=newPptxToPdfConverter("presentation.pptx",funoptions->options.PreserveDocumentStructure<-true)// Convert PPTX to PDF
converter.Convert("accessible.pdf")0
The examples in this section shows how you can adjust the output using PdfConvertOptions.
Convert Specific PPTX Slides to PDF
To convert only a portion of the presentation instead of all slides. You can specify which slides to include in the output PDF using the Pages property of PdfConvertOptions class.
As an alternative you can use PageNumber to specify the slide number to start conversion from and PagesCount to set number of slides to convert starting from PageNumber.
The following example shows how to convert the first three slides of a PPTX presentation to PDF:
usingSystem;usingSystem.Collections.Generic;usingGroupDocs.Conversion.LowCode;// Load license keysvarpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");varprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");// Apply licenseLicense.Set(publicKey,privateKey);// Create the convertervarconverter=newPptxToPdfConverter("presentation.pptx");// Save first three slides to PDFconverter.Convert("slides-1-2-3.pdf",(convertOptions)=>{convertOptions.Pages=newList<int>{1,2,3};});
ImportsSystemImportsSystem.Collections.GenericImportsGroupDocs.Conversion.LowCodeModuleProgramSubMain()' Load license keys
DimpublicKeyAsString=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")DimprivateKeyAsString=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")' Apply license
License.Set(publicKey,privateKey)' Create the converter
DimconverterAsNewPptxToPdfConverter("presentation.pptx")' Save first three slides to PDF
converter.Convert("slides-1-2-3.pdf",Sub(convertOptions)convertOptions.Pages=NewList(OfInteger)From{1,2,3}EndSub)EndSubEndModule
openSystemopenSystem.Collections.GenericopenGroupDocs.Conversion.LowCode[<EntryPoint>]letmainargv=// Load license keys
letpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")letprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")// Apply license
License.Set(publicKey,privateKey)// Create the converter
letconverter=newPptxToPdfConverter("presentation.pptx")// Save first three slides to PDF
converter.Convert("slides-1-2-3.pdf",funconvertOptions->convertOptions.Pages<-List<int>([1;2;3]))0//returnexitcode