Load Presentation document with options

The GroupDocs.Conversion for Java library allows developers to load presentation files such as PPT, PPTX, and other formats into their applications with precise control over the loading process through customizable PresentationLoadOptions. This functionality supports advanced scenarios, including specifying slide numbers, handling hidden slides, or managing password-protected presentations.

The process involves initializing the Converter class with the presentation file’s path or stream. By defining specific properties in the PresentationLoadOptions, users can, for instance, load only selected slides or ensure compatibility with particular format variations. Once loaded, the document is ready for seamless conversion into any supported output format while maintaining high fidelity and preserving the source layout.

This approach is ideal for workflows involving large-scale presentation processing, batch conversions, or integrating document handling in server-side Java applications. For this the following options could be set:

OptionDescription
setFormat()allows you to specify explicitly the type of the source presentation document. Available options are: Ppt, Pps, Pptx, Ppsx, Odp, Otp, Potx, Pot, Potm, Pptm, Ppsm.
setDefaultFont()sets a default font for rendering the presentation. The following font will be used if a presentation font is missing.
setFontSubstitutes()sets substitute specific fonts from the source presentation document.
setPassword()specifies a password to unlock the protected document.
setHideComments()specifies that comments from source presentation must be hidden during conversion.
setShowHiddenSlides()specifies that hidden slides should be included in the converted document.

Hide comments

The following code snippet shows how to convert a presentation and hide comments:

import com.groupdocs.conversion.Converter;
import com.groupdocs.conversion.options.convert.PdfConvertOptions;
import com.groupdocs.conversion.options.load.PresentationLoadOptions;

public class ConvertPresentationByHidingComments {
    public static void convert() {
        PresentationLoadOptions loadOptions = new PresentationLoadOptions();
        loadOptions.setHideComments(true);

        try(Converter converter = new Converter("sample.pptx", () -> loadOptions)) {
            PdfConvertOptions options = new PdfConvertOptions();
            converter.convert("converted_without_comments.pdf", options);
        }
    }

    public static void main(String[] args){
        convert();
    }
}

sample.pptx is sample file used in this example. Click here to download it.

converted_without_comments.pdf is converted PDF document. Click here to download it.

Specify font substitutions

The following code snippet shows how to convert a presentation and specify font substitutions for missing fonts:

import com.groupdocs.conversion.Converter;
import com.groupdocs.conversion.contracts.FontSubstitute;
import com.groupdocs.conversion.options.convert.PdfConvertOptions;
import com.groupdocs.conversion.options.load.PresentationLoadOptions;
import java.util.ArrayList;
import java.util.List;

public class ConvertPresentationBySpecifyingFontSubstitution {
    public static void convert() {
        PresentationLoadOptions loadOptions = new PresentationLoadOptions();

        List<FontSubstitute> fontSubstitutes = new ArrayList<FontSubstitute>();
        fontSubstitutes.add(FontSubstitute.create("Tahoma", "Arial"));
        fontSubstitutes.add(FontSubstitute.create("Times New Roman", "Arial"));

        loadOptions.setFontSubstitutes(fontSubstitutes);

        try(Converter converter = new Converter("sample.pptx", () -> loadOptions)) {
            PdfConvertOptions options = new PdfConvertOptions();
            converter.convert("converted_with_substitutes.pdf", options);
        }
    }

    public static void main(String[] args){
        convert();
    }
}

sample.pptx is sample file used in this example. Click here to download it.

converted_with_substitutes.pdf is converted PDF document. Click here to download it.

Include hidden slides

The following code snippet shows how to convert a presentation including the hidden slides:

import com.groupdocs.conversion.Converter;
import com.groupdocs.conversion.options.convert.PdfConvertOptions;
import com.groupdocs.conversion.options.load.PresentationLoadOptions;

public class ConvertPresentationWithHiddenSlidesIncluded {
    public static void convert() {
        PresentationLoadOptions loadOptions = new PresentationLoadOptions();
        loadOptions.setShowHiddenSlides(true);

        try(Converter converter = new Converter("with_hidden_page.pptx", () -> loadOptions)) {
            PdfConvertOptions options = new PdfConvertOptions();
            converter.convert("converted_with_hidden_slides.pdf", options);
        }
    }

    public static void main(String[] args){
        convert();
    }
}

with_hidden_page.pptx is sample file used in this example. Click here to download it.

converted_with_hidden_slides.pdf is converted PDF document. Click here to download it.