Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active January 26, 2021 03:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/b574e868e8f1a074e5cd113608184e3e to your computer and use it in GitHub Desktop.
Save aspose-com-gists/b574e868e8f1a074e5cd113608184e3e to your computer and use it in GitHub Desktop.
Convert Markdown MD file to PDF or Image like PNG, JPG, TIFF
// Convert Markdown to HTML document
HTMLDocument document = Converter.convertMarkdown(dataDir + "document.md");
try {
// Convert HTML document to PNG image file format
Converter.convertHTML(
document,
new ImageSaveOptions(
ImageFormat.Png
),
dataDir + "output_md.png"
);
} finally {
if (document != null) {
document.dispose();
}
}
// Load input MD file and Convert Markdown to HTML document
Converter.convertMarkdown(dataDir + "document.md", dataDir + "document.html");
// Convert HTML file to output PDF file format
Converter.convertHTML(dataDir + "document.html", new PdfSaveOptions(), dataDir + "output_md.pdf");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment