Can I Get a Compression Jpeg Image from PDF ?

back to home  >  Tech FAQ  >  Pass PDF page to image with Jpeg format and compression using C#


Hi, support team.

I'm developing a windows form application, and I'd like to get jpeg image with compression from PDF page. Does your .net PDF to Image SDK support?

---- Edgar


Hi, Edgar.

The pqScan .net PDF to Image control usually convert PDF page to Microsoft Bitmap object without compressed. After rendering the bitmap object, there are two ways to compress a jpeg image in Microsoft drawing APIs. One is to decrease the jpeg graphics quality, the other is compress image by jpeg compressing mode. Please see the C# demo code below, we will introduce you how to reduce graphs quality of jpg image in details.

using System;
using PQScan.PDFToImage;
using System.Drawing;
using System.Drawing.Imaging;

namespace PDFtoImageQuestion1
    class Program
        static void Main(string[] args)
            //open your PDF document
            PDFDocument doc = new PDFDocument();
            //pass first page to image
            Bitmap bmp = doc.ToImage(0);

            //set compression quality
            EncoderParameters ep = new EncoderParameters();
            long[] qty = new long[1];
            //the compression ratio need to be 1-100 
            qty[0] = 80;

            EncoderParameter eParam = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, qty);
            ep.Param[0] = eParam;

            bmp.Save("compressed.jpeg", GetImageCodecInfo("image/jpeg"), ep);


        static ImageCodecInfo GetImageCodecInfo(string mimeType)
            ImageCodecInfo[] CodecInfo = ImageCodecInfo.GetImageEncoders();
            foreach (ImageCodecInfo info in CodecInfo)
                if (info.MimeType == mimeType) return info;
            return null;

Hope the C# code can be helpful.

Besides jpg, pqScan .net PDF to image library is also able to convert PDF document to other commonly used raster images, such as bmp, gif, png and tiff. If you want to export compressed tiff image, you can do the similar operation to the compressed jpg in your .net projects. What's more, there are more compress mode to render a tif picture, such as CCITT group3 mode, CCITT group4 mode, LZW compressing mode, even you can use jpeg compressing mode to compress tif image.

---- pqScan Support Team

Online Demo Download Trial Problem with converting PDF to image in Mac. How to use .NET PDF converter in Mono? Can .net PDF to image converter integrate to Windows7 or Windows8? Can I Get a Compression Jpeg Image from PDF ? How to convert PDF to high quality image in C#? How to get transparent background png from PDF document in C#? Support Converting specific pages from PDF to images in C# .NET ? Converting specific languagePDF to images is possible? Is convert special page size PDF to image possible? Converting specific style PDF to images is allowed?