Use the page_numbers property of ConvertOptions to convert only selected pages (or worksheets) from the source document. Page numbering starts from 1.
Using static method
fromgroupdocs.markdownimportMarkdownConverter,ConvertOptionsdefconvert_specific_pages_static():"""Convert only specific pages from a document using the static API."""# Step 1: Specify which pages to convert (1-based numbering)options=ConvertOptions()options.page_numbers=[1,3]# convert only pages 1 and 3# Step 2: Convert selected pages using keyword argument for optionsMarkdownConverter.to_file("business-plan.docx","convert-pages-static.md",convert_options=options)if__name__=="__main__":convert_specific_pages_static()
business-plan.docx is sample file used in this example. Click here to download it.
fromgroupdocs.markdownimportMarkdownConverter,ConvertOptionsdefconvert_specific_pages_instance():"""Convert only specific pages from a document using the instance API."""# Step 1: Open the document with a context managerwithMarkdownConverter("business-plan.docx")asconverter:# Step 2: Specify which pages to convert (1-based numbering)options=ConvertOptions()options.page_numbers=[1,3]# convert only pages 1 and 3# Step 3: Convert and save the resultconverter.convert("convert-pages-instance.md",convert_options=options)if__name__=="__main__":convert_specific_pages_instance()
business-plan.docx is sample file used in this example. Click here to download it.
fromgroupdocs.markdownimportMarkdownConverter,ConvertOptionsdefconvert_specific_pages_to_file():"""Convert specific pages from a PDF and save the result to a file."""# Step 1: Specify which pages to convert (1-based numbering)options=ConvertOptions()options.page_numbers=[2,4,5]# convert pages 2, 4, and 5# Step 2: Convert and save to file using keyword argument for optionsMarkdownConverter.to_file("business-plan.pdf","convert-pages-to-file.md",convert_options=options)if__name__=="__main__":convert_specific_pages_to_file()
business-plan.pdf is sample file used in this example. Click here to download it.
**Table of Contents**
Meridian Outdoor Co. — Business Plan .........................................................................................1FY2026 Strategic Plan.................................................................................................................1Table of Contents.............................................................................................................................2
1. Executive Summary..................................................
[TRUNCATED]