Convert PDF files

Portable Document Format (PDF) was developed to introduce a standard for document representation and other reference material in a format that is independent of application software, hardware as well as from operating systems. Content of PDF files is not limited to text only, it could be hyperlinks, images, interactive buttons and forms, electronic signatures, watermarks, and many more. Therefore, it is often needed to convert PDF files to some other formats to edit or modify their content. Using GroupDocs.Conversion for .NET library you can convert PDF files to a wide range of popular file formats, and all you need for this is just several lines of lines code in C# programming language.

GroupDocs.Conversion for .NET supports different kinds of conversions from PDF documents to other file formats, and also conversion from different formats to PDF. You can examine conversion quality and accuracy online by using GroupDocs.Conversion App live demo. It works on any device and is free.

Supported PDF file Conversions

FromTo
PDFeBook: AZW3, EPUB, MOBI
Image: BMP, DCM, DICOM, EMF, EMZ, GIF, ICO, JP2, JPEG, JPG, PNG, PSB, PSD, SVGZ, TGA, TIF, TIFF, WEBP, WMF, WMZ
Page Description Language: EPS, PCL, PS, SVG, TEX, XPS
PDF: PDF
Presentation: FODP, ODP, OTP, POT, POTM, POTX, PPS, PPSM, PPSX, PPT, PPTM, PPTX
Spreadsheet: CSV, DIF, FODS, ODS, SXC, TSV, XLAM, XLS, XLSB, XLSM, XLSX, XLT, XLTM, XLTX
Web: HTM, HTML, MHT, MHTML
Word Processing: DOC, DOCM, DOCX, DOT, DOTM, DOTX, MD, ODT, OTT, RTF, TXT

Convert PDF to Word

Microsoft Word is one of the most convenient ways to edit and manage document content, that’s why PDF to Word conversion is so popular. Transforming a PDF file to a Word document in a manual way could be a tricky and lengthy process. Much easier is to convert PDF to Word programmatically in C#. This way any file created as PDF could be converted to a Word document for later content manipulations and editing text, tables, images, lists, etc.

GroupDocs.Conversion for .NET supports PDF conversion to all popular formats of Microsoft Word like - DOC, DOCX, RTF, etc. The document transformation process is quite simple and straightforward from the user’s point of view - all you need is two-three lines of code. The default format for PDF to Word conversion is DOCX - it’s a well-known format for Microsoft Word 2007 and later versions which is a combination of XML and binary files.
Here is a code snippet for PDF to DOCX conversion:

// Load the source PDF file
using (var converter = new GroupDocs.Conversion.Converter("sample.pdf"))
{
    // Set the convert options for DOCX format
   var options = new WordProcessingConvertOptions();
    // Convert to DOCX format
    converter.Convert("converted.docx", options);
}

or using fluent syntax

FluentConverter
    .Load("sample.pdf")
    .ConvertTo("converted.docx")
    .Convert();

GroupDocs.Conversion for .NET also provides the WordProcessingFileType class if you need to specify another Word file format as a target for your conversion. For example, DOC format represents documents generated by Microsoft Word 97-2003 and still is quite popular and the code snippet for PDF to DOC conversion is the following:

// Load the source PDF file
using (var converter = new GroupDocs.Conversion.Converter("sample.pdf"))
{
    // Set the convert options for DOC format
    var options = new WordProcessingConvertOptions  
    {  
      Format = GroupDocs.Conversion.FileTypes.WordProcessingFileType.Doc  
    };
    // Convert to DOC format
    converter.Convert("converted.doc", options);
}

or using fluent syntax

FluentConverter
    .Load("sample.pdf")
    .ConvertTo("converted.doc").WithOptions(new WordProcessingConvertOptions  
    {  
      Format = GroupDocs.Conversion.FileTypes.WordProcessingFileType.Doc  
    })
    .Convert();

Convert PDF to Excel

Spreadsheet formats are designed to represent data in the form of rows and columns, and this way tables are much easier to use. Therefore, when it’s required to transform data from a PDF file into Excel format GroupDocs.Conversion library comes to the rescue.

You can choose from a wide range of supported spreadsheet formats:

  • Microsoft Excel - XLS, XLSX, XLSM, XLSB, XLTX, XLT;
  • OpenDocument - ODS, OTS;
  • Apple iWork Numbers.

Required spreadsheet format can be specified with the help of the SpreadsheetFileType class, however, the default format for PDF to Spreadsheet conversion is XLSX. Please check below how to convert PDF to Excel in C# in a few lines of code.

// Load the source PDF file
using (var converter = new GroupDocs.Conversion.Converter("sample.pdf"))
{
    // Set the convert options for XLSX format
    var options = new SpreadsheetConvertOptions();
    // Convert to XLSX format
    converter.Convert("converted.xlsx", options);
}

or using fluent syntax

FluentConverter
    .Load("sample.pdf")
    .ConvertTo("converted.xlsx")
    .Convert();

Convert PDF to PowerPoint

Presentation file formats store collections of records to accommodate data such as slides, shapes, text, animations, video, audio, and embedded objects. The most popular app for creating and editing presentations is Microsoft PowerPoint with its PPT and PPTX file formats, though there are plenty of applications that work with OpenDocument formats like ODP and OTP.

GroupDocs.Conversion for .NET is a wise choice when you have to convert a PDF file into PowerPoint format, and here is what the code snippet looks like for PDF to PPTX conversion in C# language:

// Load the source PDF file
using (var converter = new GroupDocs.Conversion.Converter("sample.pdf"))
{
    // Set the convert options for PPTX format
   var options = new PresentationConvertOptions();
    // Convert to PPTX format
    converter.Convert("converted.pptx", options);
}

or using fluent syntax

FluentConverter
    .Load("sample.pdf")
    .ConvertTo("converted.pptx")
    .Convert();

In case you need to convert PDF to another presentation format please use the PresentationFileType class to specify it.

Convert PDF to Image

A popular use case is when you need to save the whole PDF document or some specific document pages as a collection of images. GroupDocs.Conversion for .NET allows converting PDF to images of many popular formats like - TIFF, JPG, PNG, GIF, BMP, and many others. The code snippet for such conversion is a bit different from other conversions as you have to declare a SavePageStream delegate that specifies the name format for the saved images. You can choose the desired image format by using the ImageFileType class.

Convert PDF to PNG

Please check a complete code example of PDF to PNG conversion below:

With v24.10 and later:

// Load the source PDF file
using (var converter = new GroupDocs.Conversion.Converter("sample.pdf"))
{
    Func<SavePageContext, Stream> getPageStream = saveContext => new FileStream(string.Format("converted-page-{0}.png", saveContext.Page), FileMode.Create);

    // Set the convert options for PNG format
    var options = new ImageConvertOptions { Format = GroupDocs.Conversion.FileTypes.ImageFileType.Png };
    // Convert to PNG format
    converter.Convert(getPageStream, options);
}

Before v24.10:

// Load the source PDF file
using (var converter = new GroupDocs.Conversion.Converter("sample.pdf"))
{
    Func<int, Stream> getPageStream = page => new FileStream(string.Format("converted-page-{0}.png", page), FileMode.Create);

    // Set the convert options for PNG format
    var options = new ImageConvertOptions { Format = GroupDocs.Conversion.FileTypes.ImageFileType.Png };
    // Convert to PNG format
    converter.Convert(getPageStream, options);
}

or using fluent syntax

With v24.10 and later:

FluentConverter
    .Load("sample.pdf")
    .ConvertByPageTo(saveContext => new FileStream(string.Format("converted-page-{0}.png", saveContext.Page), FileMode.Create))
    .WithOptions(new ImageConvertOptions { Format = GroupDocs.Conversion.FileTypes.ImageFileType.Png })
    .Convert();

Before v24.10:

FluentConverter
    .Load("sample.pdf")
    .ConvertByPageTo((int page) => new FileStream(string.Format("converted-page-{0}.png", page), FileMode.Create))
    .WithOptions(new ImageConvertOptions { Format = GroupDocs.Conversion.FileTypes.ImageFileType.Png })
    .Convert();

Convert PDF to JPG

The PDF to JPG conversion is another popular use case and the code snippet for it is similar to what was described before. The only difference is the output image files extension and the ImageConvertOptions.Format property that should be set to ImageFileType.Jpg:

With v24.10 and later:

// Load the source PDF file
using (var converter = new GroupDocs.Conversion.Converter("sample.pdf"))
{
    Func<SavePageContext, Stream> getPageStream = saveContext => new FileStream(string.Format("converted-page-{0}.jpg", saveContext.Page), FileMode.Create);

    // Set the convert options for JPG format
    var options = new ImageConvertOptions { Format = GroupDocs.Conversion.FileTypes.ImageFileType.Jpg };
    // Convert to JPG format
    converter.Convert(getPageStream, options);
}

Before v24.10:

// Load the source PDF file
using (var converter = new GroupDocs.Conversion.Converter("sample.pdf"))
{
    Func<int, Stream> getPageStream = page => new FileStream(string.Format("converted-page-{0}.jpg", page), FileMode.Create);

    // Set the convert options for JPG format
    var options = new ImageConvertOptions { Format = GroupDocs.Conversion.FileTypes.ImageFileType.Jpg };
    // Convert to JPG format
    converter.Convert(getPageStream, options);
}

or using fluent syntax

With v24.10 and later:

FluentConverter
    .Load("sample.pdf")
    .ConvertByPageTo((SavePageContext saveContext) => new FileStream(string.Format("converted-page-{0}.jpg", saveContext.Page), FileMode.Create))
    .WithOptions(new ImageConvertOptions { Format = GroupDocs.Conversion.FileTypes.ImageFileType.Jpg })
    .Convert();

Before v24.10:

FluentConverter
    .Load("sample.pdf")
    .ConvertByPageTo((int page) => new FileStream(string.Format("converted-page-{0}.jpg", page), FileMode.Create))
    .WithOptions(new ImageConvertOptions { Format = GroupDocs.Conversion.FileTypes.ImageFileType.Jpg })
    .Convert();

Convert PDF to TIFF

Tagged Image File Format (TIFF) is a little bit special since it can contain multi-page images. So when converting PDF to TIFF you can either save each page as a separate image or save it as a multi-page image.

To save each page separately, use the SavePageStream delegate and specify the output format by using the ImageFileType class:

With v24.10 and later:

// Load the source PDF file
using (var converter = new GroupDocs.Conversion.Converter("sample.pdf"))
{
    Func<SavePageContext, Stream> getPageStream = saveContext => new FileStream(string.Format("converted-page-{0}.tiff", saveContext.Page), FileMode.Create);

    // Set the convert options for TIFF format
    var options = new ImageConvertOptions { Format = GroupDocs.Conversion.FileTypes.ImageFileType.Tiff };
    // Convert to TIFF format
    converter.Convert(getPageStream, options);
}

Before v24.10:

// Load the source PDF file
using (var converter = new GroupDocs.Conversion.Converter("sample.pdf"))
{
    Func<int, Stream> getPageStream = page => new FileStream(string.Format("converted-page-{0}.tiff", page), FileMode.Create);

    // Set the convert options for TIFF format
    var options = new ImageConvertOptions { Format = GroupDocs.Conversion.FileTypes.ImageFileType.Tiff };
    // Convert to TIFF format
    converter.Convert(getPageStream, options);
}

or using fluent syntax

With v24.10 and later:

FluentConverter
    .Load("sample.pdf")
    .ConvertByPageTo((SavePageContext saveContext) => new FileStream(string.Format("converted-page-{0}.tiff", saveContext.Page), FileMode.Create))
    .WithOptions(new ImageConvertOptions { Format = GroupDocs.Conversion.FileTypes.ImageFileType.Tiff })
    .Convert();

Before v24.10:

FluentConverter
    .Load("sample.pdf")
    .ConvertByPageTo((int page) => new FileStream(string.Format("converted-page-{0}.tiff", page), FileMode.Create))
    .WithOptions(new ImageConvertOptions { Format = GroupDocs.Conversion.FileTypes.ImageFileType.Tiff })
    .Convert();

To save PDF as a multi-page TIFF, just specify the output format by using the ImageFileType class:

// Load the source PDF file
using (var converter = new GroupDocs.Conversion.Converter("sample.pdf"))
{
    // Set the convert options for TIFF format
    var options = new ImageConvertOptions { Format = GroupDocs.Conversion.FileTypes.ImageFileType.Tiff };
    // Convert to TIFF format
    converter.Convert("multi-page.tiff", options);
}

or using fluent syntax

FluentConverter
    .Load("sample.pdf")
    .ConvertTo("multi-page.tiff")
    .WithOptions(new ImageConvertOptions { Format = GroupDocs.Conversion.FileTypes.ImageFileType.Tiff })
    .Convert();