Convert documents with GroupDocs.Conversion

GroupDocs.Conversion turns a document of one format into another — over 170 formats in total, covering word processing, spreadsheets, presentations, PDF, email, images, CAD and more. The API is the same regardless of the direction: open the source with Converter, pick the convert options for the target format, call Convert.

Convert PDF to Word

WordProcessingConvertOptions targets the Word family. With no format specified it produces DOCX.

using GroupDocs.Conversion;
using GroupDocs.Conversion.Options.Convert;

using (Converter converter = new Converter("contract.pdf"))
{
    WordProcessingConvertOptions convertOptions = new WordProcessingConvertOptions();

    converter.Convert("conversion-pdf-to-word.docx", convertOptions);
}

contract.pdf is the sample file used in this example. Click here to download it.

Binary file (DOCX, 22 KB)

Download full output

Convert Word to PDF

The reverse direction swaps the options type. Nothing else changes — that symmetry holds for every format pair.

using GroupDocs.Conversion;
using GroupDocs.Conversion.Options.Convert;

using (Converter converter = new Converter("contract.docx"))
{
    PdfConvertOptions convertOptions = new PdfConvertOptions();

    converter.Convert("conversion-word-to-pdf.pdf", convertOptions);
}

contract.docx is the sample file used in this example. Click here to download it.

Binary file (PDF, 123 KB)

Download full output

Convert only specific pages

Converting a long document page by page is wasteful when you only need a few. Convert options accept a page range.

using GroupDocs.Conversion;
using GroupDocs.Conversion.Options.Convert;

using (Converter converter = new Converter("contract.docx"))
{
    PdfConvertOptions convertOptions = new PdfConvertOptions
    {
        PageNumber = 1,
        PagesCount = 2
    };

    converter.Convert("conversion-specific-pages.pdf", convertOptions);
}

contract.docx is the sample file used in this example. Click here to download it.

Binary file (PDF, 123 KB)

Download full output

Read source document information

GetDocumentInfo reports what the source actually is, which is worth checking before you convert a file you did not produce.

using System;
using GroupDocs.Conversion;
using GroupDocs.Conversion.Contracts;

using (Converter converter = new Converter("contract.pdf"))
{
    IDocumentInfo info = converter.GetDocumentInfo();

    Console.WriteLine("Format: " + info.Format);
    Console.WriteLine("Pages: " + info.PagesCount);
    Console.WriteLine("Size: " + info.Size + " bytes");
}

contract.pdf is the sample file used in this example. Click here to download it.

Format: pdf
Pages: 3
Size: 130412 bytes

Download full output

Learn more

Beyond the basics, GroupDocs.Conversion loads sources from streams, URLs and cloud storage, converts to and from spreadsheets, presentations, images, ebooks and CAD drawings, applies watermarks during conversion, and offers a fluent API for chained operations.

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.