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.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 also provides the feature to convert selected page number. 

To convert specific pages, follow these steps: 

  1. Create an instance of the Converter class and pass source document path as a constructor parameter.
  2. Instantiate the appropriate ConvertOptions class e.g. (PdfConvertOptions, WordProcessingConvertOptions, SpreadsheetConvertOptions etc.)
  3. Set the setPages property of the ConvertOptions instance to the list of desired page number to be converted.
  • Call the convert method of the Converter class instance and pass the filename of the converted document and the instance of ConvertOptions from the previous steps.

The following code snippet shows how to convert first and third pages from the source document:

const converter = new groupdocs.conversion.Converter('sample.docx')
const convertOptions = new groupdocs.conversion.PdfConvertOptions()

const pages = new ArrayList()
pages.add(1)
pages.add(3)
convertOptions.setPages(pages);

converter.convert('outputSpecPages.pdf', convertOptions)