Convert to Image

GroupDocs.Conversion can convert any source document to the following image formats: Tiff, Tif, Jpg, Jpeg, Png, Gig, Bmp, Ico, Psd, Wmf, Emf, Dcm, Webp, Dng, Svg, Jp2, Odg, J2c, J2k, Jpx, Jpf, Jpm, Eps, Cgm, Cdr, Cmx, Dib, Jpc, Jls, DjVu. When just instantiate the ImageConvertOptions class without specifying the target format explicitly, Jpg will be used as a default format.

Conversion to image format could be triggered by following below steps:

Conversion to JPG

The following code show how to convert any document to JPG. 

string outputFileTemplate = Path.Combine(outputFolder, "converted-page-{0}.jpg");
SavePageStream getPageStream = page => new FileStream(string.Format(outputFileTemplate, page), FileMode.Create);
using (Converter converter = new Converter("sample.pdf"))
{
    ImageConvertOptions options = new ImageConvertOptions
    {
        Format = ImageFileType.Jpg
    };
    
    converter.Convert(getPageStream, options);
}

Conversion to PNG

The following code show how to convert any document to PNG. 

string outputFileTemplate = Path.Combine(outputFolder, "converted-page-{0}.png");
SavePageStream getPageStream = page => new FileStream(string.Format(outputFileTemplate, page), FileMode.Create);
using (Converter converter = new Converter("sample.pdf"))
{
    ImageConvertOptions options = new ImageConvertOptions
    {
        Format = ImageFileType.Png
    };
    
    converter.Convert(getPageStream, options);
}

Conversion to PSD

The following code show how to convert any document to PSD. 

string outputFileTemplate = Path.Combine(outputFolder, "converted-page-{0}.psd");
SavePageStream getPageStream = page => new FileStream(string.Format(outputFileTemplate, page), FileMode.Create);
using (Converter converter = new Converter("sample.pdf"))
{
    ImageConvertOptions options = new ImageConvertOptions
    {
        Format = ImageFileType.Psd
    };
    
    converter.Convert(getPageStream, options);
}

More resources

Advanced Usage Topics

To learn more about convert file features, please refer to the advanced usage section.

Examples and Demos

Please find more use-cases and complete C# sources of our backend and frontend examples and try them for free!