GroupDocs.Markdown provides two ways to load a file from a local disk: the static one-liner API and the instance-based API.
Using static method
The simplest approach – pass a file path and get the Markdown string back:
fromgroupdocs.markdownimportMarkdownConverterdefload_from_disk_static():"""Load and convert a local file to Markdown using the static API."""# Convert a local file directly to a Markdown file on diskMarkdownConverter.to_file("business-plan.docx","load-disk-static.md")if__name__=="__main__":load_from_disk_static()
business-plan.docx is sample file used in this example. Click here to download it.
When you need more control (e.g., conversion options, document info), create a MarkdownConverter instance:
fromgroupdocs.markdownimportMarkdownConverterdefload_from_disk_instance():"""Load a local file with the instance API, then convert it."""# Step 1: Open the document with a context managerwithMarkdownConverter("business-plan.docx")asconverter:# Step 2: Convert to Markdown and save the resultconverter.convert("load-disk-instance.md")if__name__=="__main__":load_from_disk_instance()
business-plan.docx is sample file used in this example. Click here to download it.