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-specific-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.
| HOME BASED | | |
| --- | --- | --- |
| | | |
| PROFESSIONAL SERVICES | | |
| | Business Plan | |
| Introduction |
| --- |
| :"""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-specific-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.
| HOME BASED | | |
| --- | --- | --- |
| | | |
| PROFESSIONAL SERVICES | | |
| | Business Plan | |
| Introduction |
| --- |
| :"""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-specific-pages.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** ![](data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCAOhAVcDASIAAhEBAxEB/8QAHQAAAgMBAQEBAQAAAAAAAAAAAAQFBgcIAwEJAv/EAGYQAAACBAoHBQUEBAoGBQsBCQMEAAEFEQYTFCExQVFhgfAkcZGhscHhBxUjNNElM0RU8RY1Q2QCRXSCCBJSU1VjZXWEoiZChZTC4jI2laXFFyJGVnJzkqS0tdLWJzdidobV5Ob0/8QAGwEBAQEAAwEBAAAAAAAAAAAAAAQFAQM
[TRUNCATED]