Convert documents with GroupDocs.Conversion
Leave feedback
On this page
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.
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)
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)
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)
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
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.
- GroupDocs.Conversion for .NET documentation — the full product guide
- Supported file formats
- API reference
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.