<repositories>
<repository>
<id>repository.groupdocs.com</id>
<name>GroupDocs Repository</name>
<url>https://releases.groupdocs.com/java/repo/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.groupdocs</groupId>
<artifactId>groupdocs-markdown</artifactId>
<version>26.5</version>
</dependency>
</dependencies>repositories {
maven {
url 'https://releases.groupdocs.com/java/repo/'
}
}
compile(group: 'com.groupdocs', name: 'groupdocs-markdown', version: '26.5')<ivysettings>
<settings defaultResolver="chain"/>
<resolvers>
<chain name="chain">
<ibiblio name="GroupDocs Repository" m2compatible="true" root="https://releases.groupdocs.com/java/repo/"/>
</chain>
</resolvers>
</ivysettings>
<dependency org="com.groupdocs" name="groupdocs-markdown" rev="26.5">
<artifact name="groupdocs-markdown" ext="jar"/>
</dependency>resolvers += Resolver.url("GroupDocs Repository", url("https://releases.groupdocs.com/java/repo/"))
libraryDependencies += "com.groupdocs" % "groupdocs-markdown" % "26.5"GroupDocs.Markdown for Java Downloads
Powerful document processing API for Java to export PDF, Word, Excel, and other formats to Markdown for seamless integration with the generative AI ecosystem. Accurately export headings, paragraphs, lists, tables, links, images, blockquotes, and code blocks with flexible image handling options.
Quick links
Key Features
- Export multiple document formats: Convert popular file types (PDF, DOCX, XLSX, EPUB, and more) to Markdown.
- Advanced Markdown formatting: Accurately export headings, paragraphs, lists, tables, links, images, blockquotes, and code blocks.
- Markdown flavor control: Target GitHub Flavored Markdown or CommonMark.
- Flexible image handling: Export images separately or embed them directly into the Markdown file.
- Document inspection: Read format and page count without running a conversion, and discover the supported formats at runtime.
- URI resources: Load a document straight from a web address, without downloading it first.
- Spreadsheet rendering options: Limit rows and columns, set a sheet separator, and skip hidden sheets.
- Local processing: No cloud or internet connection required. All processing happens securely on your machine.
Supported Formats
- Portable Document Format: PDF
Spreadsheets
- Microsoft Excel: XLS, XLSX, XLSB, XLSM, XLT, XLTX, XLTM, XLAM
- OpenDocument Spreadsheet: ODS, OTS, FODS
- Other: CSV, TSV, NUMBERS, SXC
Word / Rich Text
- Microsoft Word: DOC, DOCX, DOT, DOTM, DOTX, DOCM, RTF
- OpenDocument Text: ODT, OTT
Ebooks
- eBook: AZW3, MOBI, EPUB
Text / Markup / Help
- Other: CHM, XML, TXT
See the full list of supported formats.
Getting Started
Prerequisites
- Java Runtime Environment (JRE) 8 or later
- Windows or Linux
Installation
To install the package, check the System Requirements and Installation documentation topics for platform-specific instructions.
Use cases
Here are some typical use cases:
Convert document to Markdown
This example shows how to convert a DOCX file to Markdown format.
import com.groupdocs.markdown.*;
public class Main {
public static void main(String[] args) {
// Set the license (optional)
License.setLicense("GroupDocs.Markdown.lic");
// Convert and return the Markdown content as a string
String markdown = MarkdownConverter.toMarkdown("sample.docx");
// Or convert straight to a file
MarkdownConverter.toFile("sample.docx", "result.md");
}
}
The output result.md file contains the converted Markdown content with images embedded by default.
Convert with custom image handling and a target flavor
import com.groupdocs.markdown.*;
public class Main {
public static void main(String[] args) {
// Set the license (optional)
License.setLicense("GroupDocs.Markdown.lic");
// Instantiate converter
MarkdownConverter converter = new MarkdownConverter("sample.docx");
// Target GitHub Flavored Markdown and save images next to the output file
DocumentConvertOptions options = new DocumentConvertOptions();
options.setFlavor(MarkdownFlavor.GITHUB);
options.setImageExportStrategy(new ExportImagesToFileSystemStrategy("images"));
// Convert and report any non-fatal warnings
DocumentConvertResult result = converter.convert(options);
for (String warning : result.getWarnings()) {
System.out.println(warning);
}
}
}
This code example converts a DOCX file to Markdown and exports images separately instead of embedding them.
Inspect a document before converting it
import com.groupdocs.markdown.*;
public class Main {
public static void main(String[] args) {
// Set the license (optional)
License.setLicense("GroupDocs.Markdown.lic");
// Read the format and page count without running a conversion
DocumentInfo info = MarkdownConverter.getInfo("report.docx");
System.out.println(info.getFileFormat() + ", " + info.getPageCount() + " pages");
}
}
Convert multiple documents
This code example shows how to convert multiple documents to Markdown format.
import com.groupdocs.markdown.*;
public class Main {
public static void main(String[] args) {
// Set the license (optional)
License.setLicense("GroupDocs.Markdown.lic");
// List of documents to convert
String[] documents = {"sample.pdf", "sample.docx", "sample.xlsx"};
for (String document : documents) {
String outputFile = document + ".md";
try {
MarkdownConverter.toFile(document, outputFile);
System.out.println("Converted: " + document + " -> " + outputFile);
} catch (GroupDocsMarkdownException e) {
// Conversion methods throw on failure
System.err.println("Conversion failed for " + document + ": " + e.getMessage());
}
}
}
}
This example converts multiple documents (PDF, DOCX, XLSX) to Markdown format, creating separate output files for each.
