Created
November 4, 2025 19:43
-
-
Save aspose-com-gists/35892b58575d2d2f1053d116d9273092 to your computer and use it in GitHub Desktop.
Convert PPTX to Markdown in Java
This file contains hidden or 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
| package com.example; | |
| import com.aspose.slides.*; | |
| public class main { | |
| public static void main(String[] args) { | |
| String dataDir = "files"; | |
| License lic = new License(); | |
| lic.setLicense("license.lic"); | |
| // Path to source and output files. | |
| String presentationName = dataDir + "PresentationDemo.pptx"; | |
| String outFilePath = dataDir + "pres-out-file.md"; | |
| // Load the source PPTX/PPT file by initializing an instance of the | |
| // Presentation class. | |
| Presentation pres = new Presentation(presentationName); | |
| try { | |
| // Create an object of the MarkdownSaveOptions class. | |
| MarkdownSaveOptions options = new MarkdownSaveOptions(); | |
| // Invoke the setRemoveEmptyLines function to remove empty or | |
| // whitespace-only lines from the final Markdown output. Default is false. | |
| options.setRemoveEmptyLines(true); | |
| // The setHandleRepeatedSpaces function specifies how repeated regular | |
| // space characters should be handled during Markdown export. | |
| options.setHandleRepeatedSpaces( | |
| HandleRepeatedSpaces.AlternateSpacesToNbsp); | |
| // setSlideNumberFormat function sets the format string used for slide | |
| // number headers in Markdown output. | |
| options.setSlideNumberFormat("## Slide {0} -"); | |
| // Call the setShowSlideNumber function to specify whether the generated | |
| // document should show number of each slide or not. | |
| options.setShowSlideNumber(true); | |
| // Invoke the setExportType method to specify markdown specification to | |
| // convert presentation. Default is TextOnly. | |
| options.setExportType(MarkdownExportType.TextOnly); | |
| options.setFlavor(Flavor.Default); | |
| // Save presentation in Markdown format by calling the save method. | |
| pres.save(outFilePath, SaveFormat.Md, options); | |
| } finally { | |
| if (pres != null) pres.dispose(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment