The following example shows the most common use case for converting PowerPoint PPT document to PDF. The source PPT 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 PPT filevarconverter=newPptToPdfConverter("presentation.ppt");// Convert PPT 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
DimconverterAsNewPptToPdfConverter("presentation.ppt")' Convert PPT 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=newPptToPdfConverter("presentation.ppt")// Convert PPT 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 PPT to PDF
The following example shows how to convert protected PPT 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=newPptToPdfConverter("protected.ppt",options=>{options.Password="12345";});// Convert PPT 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
DimconverterAsNewPptToPdfConverter("protected.ppt",Sub(options)options.Password="12345"EndSub)' Convert PPT 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=newPptToPdfConverter("protected.ppt",funoptions->options.Password<-"12345")// Convert PPT 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 PPT 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=newPptToPdfConverter("with-hidden-slides.ppt",options=>{options.ShowHiddenSlides=true;});// Convert PPT 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
DimconverterAsNewPptToPdfConverter("with-hidden-slides.ppt",Sub(options)options.ShowHiddenSlides=TrueEndSub)' Convert PPT 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=newPptToPdfConverter("with-hidden-slides.ppt",funoptions->options.ShowHiddenSlides<-true)// Convert PPT to PDF
converter.Convert("with-hidden-slides.pdf")0
Convert PPT with Preserved Document Structure for Accessible PDF
The following example shows how to convert a PPT file to an accessible PDF by preserving the document structure using the PreserveDocumentStructure property. This is useful for creating PDFs that are more accessible to screen readers and assistive technologies.
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 for accessible PDFvarconverter=newPptToPdfConverter("presentation.ppt",options=>{options.PreserveDocumentStructure=true;});// Convert PPT to accessible 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 for accessible PDF
DimconverterAsNewPptToPdfConverter("presentation.ppt",Sub(options)options.PreserveDocumentStructure=TrueEndSub)' Convert PPT to accessible 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 for accessible PDF
letconverter=newPptToPdfConverter("presentation.ppt",funoptions->options.PreserveDocumentStructure<-true)// Convert PPT to accessible PDF
converter.Convert("accessible.pdf")0
The examples in this section shows how you can adjust the output using PdfConvertOptions.
Convert Specific PPT 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 PPT file 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=newPptToPdfConverter("presentation.ppt");// 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
DimconverterAsNewPptToPdfConverter("presentation.ppt")' 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=newPptToPdfConverter("presentation.ppt")// Save first three slides to PDF
converter.Convert("slides-1-2-3.pdf",funconvertOptions->convertOptions.Pages<-List<int>([1;2;3]))0//returnexitcode