Convert N consecutive 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.Conversion 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-conversion -- dnx GroupDocs.Conversion.Mcp --yes
Folders, licensing and more →

GroupDocs.Conversion provides the feature to convert N consecutive pages.

To convert consecutive pages, follow these steps:

  1. Create an instance of the Converter class and pass the source document path as a constructor parameter
  2. Instantiate the appropriate ConvertOptions class e.g. (PdfConvertOptions, WordProcessingConvertOptions, SpreadsheetConvertOptions etc.)
  3. Set the PageNumber property of the ConvertOptions instance to the starting page number
  4. Set the PagesCount property of the ConvertOptions instance to the number of pages to be converted
  5. Call the Convert method of the Converter class instance and pass the filename for the converted document and the instance of the ConvertOptions from the previous steps

The following code snippet shows how to convert 3 consecutive pages starting from second page of the source document:

using (Converter converter = new Converter("sample.docx"))
{
    PdfConvertOptions options = new PdfConvertOptions
    {
        PageNumber = 2,
        PagesCount = 3
    };
    converter.Convert("converted.pdf", options);
}