Convert specific pages

GroupDocs.Conversion also provides the feature to convert selected page number.

To convert specific pages, follow these steps:

  1. Create an instance of 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 Pages property of the ConvertOptions instance to the list of desired page number to be converted.
  4. Call the Convert method of 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:

using (Converter converter = new Converter("sample.docx"))
    PdfConvertOptions options = new PdfConvertOptions
        Pages = new List<int>{ 1, 3 }
    converter.Convert("converted.pdf", options);