For more details, please visit Convert Markdown MD File to Word Document DOCX/DOC or XPS File in C#
Last active
December 23, 2021 06:03
-
-
Save aspose-com-gists/5fdd0ccec10356ff52d256a5d14db5fa to your computer and use it in GitHub Desktop.
Convert Markdown .md file to Word Document DOCX/DOC or XPS File
This file contains 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
// Prepare a path to a source Markdown file | |
string sourcePath = dataDir + "nature.md"; | |
// Prepare a path for converted DOCX file saving | |
string savePath = dataDir + "nature-output.docx"; | |
// Convert Markdown to HTML document | |
HTMLDocument document = Converter.ConvertMarkdown(sourcePath); | |
// Initialize DocSaveOptions. Set up the page-size and margins | |
DocSaveOptions options = new DocSaveOptions(); | |
options.PageSetup.AnyPage = new Page(new Size(500, 1000), new Margin(20, 20, 10, 10)); | |
// Convert HTML document, created from Markdown file to DOCX file format | |
Converter.ConvertHTML(document, options, savePath); |
This file contains 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
// Prepare a path to a source Markdown file | |
string sourcePath = dataDir + "nature.md"; | |
// Prepare a path for converted PDF file saving | |
string savePath = dataDir + "nature-output.xps"; | |
// Convert Markdown to HTML | |
var document = Converter.ConvertMarkdown(sourcePath); | |
// Initialize XpsSaveOptions. Set up the resilutions, page-size, margins and change the background color to AntiqueWhite | |
var options = new Aspose.Html.Saving.XpsSaveOptions() | |
{ | |
HorizontalResolution = 200, | |
VerticalResolution = 200, | |
BackgroundColor = System.Drawing.Color.AntiqueWhite | |
}; | |
options.PageSetup.AnyPage = new Page(new Size(Length.FromInches(5.0f), Length.FromInches(10.0f)), new Margin(30, 20, 10, 10)); | |
// Convert the Markdown MD file to XPS file format | |
Converter.ConvertHTML(document, options, savePath); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment