pq scan
Question:
Hi, support team.
I'm developing a windows from application, and I'd like to get jpeg image with compression from PDF page. Does your PDF to Image SDK support?
---- Edgar
Hi, support team.
I'm developing a windows from application, and I'd like to get jpeg image with compression from PDF page. Does your PDF to Image SDK support?
---- Edgar
Hi, Edgar.
The Library can provide you the uncompressed Bitmap converted from PDF page. Then you can compress this image as Jpeg format using C# .NET yourself.
Please see the C# code below:
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 = newPDFDocument(); doc.LoadPDF("sample.pdf"); //pass first page to image Bitmap bmp = doc.ToImage(0); //set compression quality EncoderParameters ep = newEncoderParameters(); long[] qty = newlong[1]; //the compression ratio need to be 1-100 qty[0] = 80; EncoderParameter eParam = newEncoderParameter(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.
---- pqScan Support Team
Copyright © pqScan 2010-2023. All Rights Reserved.