Convert specific pages

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Markdown MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-markdown -- dnx GroupDocs.Markdown.Mcp --yes
Folders, licensing and more →

Use the setPageNumbers method of DocumentConvertOptions to convert only selected pages (or worksheets) from the source document. Page numbering starts from 1.

Using static method

import com.groupdocs.markdown.*;

public class SpecificPagesStatic {

    public static void main(String[] args) {
        DocumentConvertOptions options = new DocumentConvertOptions();
        options.setPageNumbers(new int[] { 1, 3 });

        // Convert only pages 1 and 3
        MarkdownConverter.toFile("business-plan.docx", "specific-pages-static.md", options);
    }
}

business-plan.docx is a sample file used in this example. Click here to download it.

![](data:...;base64,[elided])

**Meridian Outdoor Co. — Business Plan**

FY2026 Strategic Plan


# **1. Executive Summary**

Meridian Outdoor Co. is a direct-to-consumer outdoor apparel and gear brand serving thru-hikers, backcountry travelers, and weekend adventurers. This plan outlines our strategy for fiscal year 2026, a year in which we expect to grow revenue by forty percent, expand into three new retail categories, and launch our sustainability certification program.
[TRUNCATED]

Download full output

Using instance API

import com.groupdocs.markdown.*;

public class SpecificPagesInstance {

    public static void main(String[] args) {
        try (MarkdownConverter converter = new MarkdownConverter("business-plan.docx")) {
            DocumentConvertOptions options = new DocumentConvertOptions();
            options.setPageNumbers(new int[] { 1, 3 });

            converter.convert("specific-pages-instance.md", options);
        }
    }
}

business-plan.docx is a sample file used in this example. Click here to download it.

![](data:...;base64,[elided])

**Meridian Outdoor Co. — Business Plan**

FY2026 Strategic Plan


# **1. Executive Summary**

Meridian Outdoor Co. is a direct-to-consumer outdoor apparel and gear brand serving thru-hikers, backcountry travelers, and weekend adventurers. This plan outlines our strategy for fiscal year 2026, a year in which we expect to grow revenue by forty percent, expand into three new retail categories, and launch our sustainability certification program.
[TRUNCATED]

Download full output

Save specific pages to a file

import com.groupdocs.markdown.*;

public class SpecificPagesFile {

    public static void main(String[] args) {
        DocumentConvertOptions options = new DocumentConvertOptions();
        options.setPageNumbers(new int[] { 2, 4, 5 });

        MarkdownConverter.toFile("business-plan.pdf", "specific-pages-file.md", options);
    }
}

business-plan.pdf is a sample file used in this example. Click here to download it.

**Table of Contents**

MeridianOutdoorCo.—BusinessPlan.........................................................................................1

FY2026StrategicPlan.................................................................................................................1

TableofContents.............................................................................................................................2

1.ExecutiveSummary..........................................................
[TRUNCATED]

Download full output