By default, ConvertOptions uses ExportImagesAsBase64Strategy, which embeds images as Base64 data URIs directly in the Markdown output. This keeps the output self-contained in a single file with no external image dependencies.
Using static method
fromgroupdocs.markdownimportMarkdownConverterdefbase64_static():"""Convert a PDF to Markdown with images embedded as Base64 (default behavior)."""# Step 1: Convert the document -- images are embedded as Base64 by defaultmarkdown=MarkdownConverter.to_markdown("business-plan.pdf")# Step 2: Print the self-contained Markdown outputprint(markdown)if__name__=="__main__":base64_static()
business-plan.pdf is sample file used in this example. Click here to download it.
If you want to be explicit, set image_export_strategy to a new ExportImagesAsBase64Strategy:
fromgroupdocs.markdownimportMarkdownConverter,ConvertOptions,ExportImagesAsBase64Strategydefbase64_explicit():"""Explicitly set the Base64 image strategy and convert using the instance API."""# Step 1: Explicitly configure the Base64 image export strategyoptions=ConvertOptions()options.image_export_strategy=ExportImagesAsBase64Strategy()# Step 2: Open the document with a context managerwithMarkdownConverter("business-plan.pdf")asconverter:# Step 3: Convert using keyword argument for optionsconverter.convert("base64-explicit.md",convert_options=options)if__name__=="__main__":base64_explicit()
business-plan.pdf is sample file used in this example. Click here to download it.