English

Document and image file conversion APIs for C# .NET and Java

Develop powerful file conversion apps in .NET and Java to convert PDF, Word, Excel, PowerPoint, Project, Diagram, Email, HTML, Ebook, CAD, PNG, PSD, and many more formats.

View all APIsTry our APIs for Free

Simple, fast, and accurate document conversions

File conversion is the process of transforming one data file format into another. This can be done for several reasons, such as to make a document compatible with a different software application or to optimize an image file. Document and image conversion are two of the most common types of format conversions used by application developers. For instance, a developer may convert a JPEG image into a PNG format so that it can be used by a graphics application. Another useful scenario is converting a Microsoft Word (DOC, DOCX) document into PDF format so that it could be viewed by a PDF viewer

Similarly, there are several other document conversion options app developers may use like building a PDF converter application or converting JSON to XLSX format to read the contents of the file in the software they are developing. If you are also looking to accurately transform your multi-format files from one data format to another, you can use the robust, scalable, and user-friendly APIs of GroupDocs.Conversion for .NET and Java platforms. The APIs provide the perfect solutions for developers who want to access and convert a multitude of documents and images easily.

Getting Started

Before diving into the conversions, please review the .NET and Java installation guides to set up your environment correctly.

File conversion use-cases

Let’s take a look at some of the popular use cases for converting your documents, images, ebooks, audio, diagrams, drawings, and numerous other types of files.

Learn to convert PDF documents to Word, Excel, PowerPoint, and image file types

PDFs are often created from scanned documents, which means that along with text, they could also contain a lot of images, watermarks, electronic signatures, and much more. So, converting PDFs would be required so that the files can be opened and edited in different programs. You can do this accurately using the conversion features of GroupDocs.Conversion APIs and convert between documents and images in .NET and Java.

Learn to convert PDF documents to Word, Excel, PowerPoint, and image file types

PDF file conversion to Microsoft Word, Excel, or PowerPoint documents in .NET

Convert PDF to Word, PDF to Excel, and PDF to PowerPoint formats in your C# .NET apps. Please use the following code block for converting PDF to DOCX:
// 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);
}    
To convert PDF to Excel, you will only need to make the following changes to the above code:
  • Replace WordProcessingConvertOptions(); constructor with SpreadsheetConvertOptions();
  • Set file extension of the converted document to .XLSX (‘converted.xlsx’) instead of .DOCX
The same applies to PDF to PPTX conversion, please make the following changes to your code:
  • Replace WordProcessingConvertOptions(); constructor with PresentationConvertOptions();
  • Set file extension of the converted document to .PPTX (‘converted.pptx’) instead of .DOCX

Easily convert PDF documents to PNG or JPG formats in .NET

PDF file conversion to image formats could be useful for viewing or editing files in image editors. Here’s how you can convert PDF to PNG images:
// Load the source PDF file
using (var converter = new GroupDocs.Conversion.Converter("sample.pdf"))
{
    GroupDocs.Conversion.Contracts.SavePageStream 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);
} 
For PDF to JPG conversion, the only change would be the output image file extension and ImageConvertOptions.Format which must be set to ImageFileType.Jpg.

Microsoft Office documents to PDF converter in Java

In this section, we will look at how to convert PDF documents to DOCX, XLSX, PPTX files, PNG, or JPG images using the document conversion APIs across your Java desktop, HTML web, and mobile apps. Convert your PDF to Word documents using this code block:
// Load the source PDF file
Converter converter = new Converter("sample.pdf");
// Set the convert options for DOCX format
WordProcessingConvertOptions options = new WordProcessingConvertOptions();
// Convert to DOCX format
converter.convert("converted.docx", options); 
To convert PDF to XLSX format, you will only need to replace:
  • WordProcessingConvertOptions with SpreadsheetConvertOptions
  • Output file extension to .XLSX (‘converted.xlsx’)
And to convert PDF to PPTX in Java using the above code, please change:
  • WordProcessingConvertOptions with PresentationConvertOptions
  • Output file extension to .PPTX (‘converted.pptx’)

Perform Java PDF to PNG and JPG conversions

For PDF document conversion to PNG format, please use this code snippet:
// Load the source PDF file
Converter converter = new Converter("sample.pdf");
SavePageStream getPageStream = page => new FileOutputStream(String.format("converted-page-%s.png", page));
// Set the convert options for PNG format
var options = new ImageConvertOptions();
options.setFormat(ImageFileType.Png);
// Convert to PNG format
 converter.convert(getPageStream, options); 
You can also make use of PDF to JPG converter functionality in Java by only changing the output image file extension and ImageConvertOptions.Format to ImageFileType.Jpg.

How to convert PNG and JPG images to PDF and MS Office formats

A simple question asked by many people is: why would I want to convert my image to PDF? The answer is simple; PDFs are universally accepted and readable by all devices and platforms. So if you want your document to be viewed on any device regardless of its operating system, converting your PNG or JPG images to PDF will be the best option for you. Likewise, you might want to convert your PNG or JPG images to Word, Excel, or PowerPoint documents for sharing, editing, printing, or storage of your files with cross-application compatibility in mind. GroupDocs.Conversion APIs for .NET and Java platforms make different types of image conversions easier for you.

How to convert PNG and JPG images to PDF and MS Office formats

Convert PNG to Word or JPG to PDF in C# .NET Applications

It's a common requirement to convert raster images such as PNG or JPG to PDF or Microsoft Word documents. The following code shows how you can create a JPG to PDF converter in C#:
// Load the source JPG file
using (var converter = new GroupDocs.Conversion.Converter("sample.jpg"))
{
    // Set the convert options for PDF format
    var options = new PdfConvertOptions();
    // Convert to PDF format
    converter.Convert("converted.pdf", options);
}   
For converting a PNG image to DOCX format, please use the following C# code snippet:
// Load the source PNG file
using (var converter = new GroupDocs.Conversion.Converter("sample.png"))
{
    var options = new WordProcessingConvertOptions();
    // Save converted DOCX file
    converter.Convert("png-converted-to.docx", options);
}   
Additionally, you can also transform your PNG and JPG images to Microsoft Excel and PowerPoint formats using GroupDocs.Conversion for .NET.

JPG to Excel and PowerPoint image conversions in Java

Java app developers can programmatically convert PNG and JPG images to Excel and PowerPoint formats in addition to the ability to convert them into PDF and Word documents with the help of GroupDocs.Conversion for Java. Use the simple code shared below to convert PNG to Excel (XLSX) format:
    // Load the source PNG  file
    Converter converter = new Converter("sample.png");
    SpreadsheetConvertOptions options = new SpreadsheetConvertOptions();
    // Save converted XLS file
    converter.convert("png-converted-to.xlsx", options); 
To convert JPG to PowerPoint (PPTX) in your Java desktop or web applications, please use the code given below:
    // Load the source JPG file
    Converter converter = new Converter("sample.jpg");
    PresentationConvertOptions options = new PresentationConvertOptions();
    // Save converted PPT file  
    converter.convert("jpg-converted-to.pptx", options); 

How to convert specific document pages to PDF format in .NET and Java

Converting specific document pages to PDF is a common need for many organizations considering PDF is a universal file type and can be opened on any device or platform without any hassle. PDFs are also more secure than traditional documents and can preserve the original document formatting, including layout, images, text formatting, and fonts. Another important characteristic of PDFs is the ability to be used as attachments without being compressed or resized. So, if you want to change certain pages within your document to PDF format in .NET or Java, GroupDocs.Conversion APIs equip you with the right toolset for this purpose.

How to convert specific document pages to PDF format in .NET and Java

Build C# .NET applications to convert particular pages of Microsoft Word to PDF

Please use the code snippet shared below to convert specific pages in Word to PDF:
        using (Converter converter = new Converter("sample.docx"))
        {
            PdfConvertOptions options = new PdfConvertOptions
            {
                Pages = new List{ 1, 3 }
            };
            converter.Convert("converted.pdf", options);
        }     

Java Word to PDF conversion of specific document pages

To transform specified pages in a Word document to PDF format, please use this code:
            Converter converter = new Converter("sample.docx");
            PdfConvertOptions options = new PdfConvertOptions();
            options.setPages(Arrays.asList( 1, 3));
            converter.convert("converted.pdf", options); 

Applying a watermark to .NET and Java documents

Adding watermarks to the output files during the conversion process could help make the exported documents secure, prevent any misuse, and avoid alterations to the document without the permission of the file owner. GroupDocs.Conversion APIs for .NET and Java let you apply watermarks to different converted data files seamlessly.

Applying a watermark to .NET and Java documents

Watermark PDF, DOCX, XLSX and PPTX documents in .NET

Use the watermarking functionality in your C# based .NET apps with the help of the code shown below:
            using (Converter converter = new Converter("sample.docx"))
        {
            WatermarkOptions watermark = new WatermarkTextOptions("Sample watermark")
            {
                Color = Color.Red,
                Width = 100,
                Height = 100,
                Background = true
            };
            PdfConvertOptions options = new PdfConvertOptions
            {
                Watermark = watermark
            };
            converter.Convert("converted.pdf", options);
        }       
To incorporate the watermark into a different file type, the only changes would be the output file extension and using the relevant ConvertOptions class (WordProcessingConvertOptions, SpreadsheetConvertOptions, PresentationConvertOptions)

Insert watermarks to PDF, Word, Excel, and PowerPoint documents in Java

The following code snippet shows how Java app developers could watermark PDF, Word documents, Excel spreadsheets, and PowerPoint presentations:
            Converter converter = new Converter("sample.docx");
        PdfConvertOptions options = new PdfConvertOptions();
        
        WatermarkOptions watermark = new WatermarkOptions();
        watermark.setText("Sample watermark");
        watermark.setColor(Color.red);
        watermark.setWidth(100);
        watermark.setHeight(100);
        watermark.setBackground(true);
        
        options.setWatermark(watermark);
        converter.convert("converted.pdf", options); 
For applying the watermark to another document format, please change the output file extension and the relevant ConvertOptions class (WordProcessingConvertOptions, SpreadsheetConvertOptions, PresentationConvertOptions) You can also convert your PDF, DOC, XLSX, PPTX, PNG, MSG, VSD, and MPP files on the fly from your desktop or mobile devices using our free online GroupDocs.Conversion Apps.

Independently automate your document and image processing tasks

Why choose GroupDocs?

Unmatched file formats support

  • All popular file formats supported including documents, images, audio, videos, and ebooks.
  • PDF, DOC, DOCX, XLS, XLSX, PPT, PPTX, PUB, PNG, PSD, ODT, MSG, EML, MP3, MP4, and many more.

Extensively programmable libraries

  • Use GroupDocs APIs to build fully customizable .NET and Java apps.
  • Manipulate your business documents, spreadsheets, presentations, and images any way you like.

Hundreds of supported features

  • Convert Word or Excel to PDF, annotate PDFs, edit DOC, DOCX, or watermark files.
  • Work with esignatures, tables, mail-merge, attachments, shapes, and much more.

Tailored to your needs

  • Free trials and different paid licensing options to choose from.
  • Well-suited to individual users, startups, as well as small and large enterprises.

APIs for Developers

  • Programmatically process your digital documents and images in .NET and Java platforms.
  • Document APIs designed specifically for .NET and Java application developers.

Trusted by users globally

  • Preferred by developers and businesses alike, our libraries are used globally.
  • Generate optimised documents easily in standalone and distributed environments.

Do more with your documents and images

  • Create, render, edit, convert, compare, digitally sign, watermark, and export your files.
  • Experience endless possibilities by creating multi-functional, high-performance apps.

Simple integration and convenient application

  • Enjoy greater flexibility by integrating with your existing software applications.
  • Get up and running using a few lines of code with our super-fast and reliable APIs.

Multiple support channels

  • Need help? Look no further than one of our developer-led support options.
  • Explore the APIs structure, and documentation, or dive into the knowledge base.

Ready to get started?

Download Free Trial