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, 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(); doc.LoadPDF("sample.pdf"); //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
Copyright © pqScan 2010-2023. All Rights Reserved.