We are converting PDF file to png image file, generally the image is in good quality, however somehow we just could not get a good quality image from one PDF file. Here is test program:
static void Main(string args)
string pdfFileName = @"\10.1.1.25.6812.pdf";
int resolution = 94
int quality = 70;
using (var pdfStream = new FileStream(pdfFileName, FileMode.Open, FileAccess.Read))
Document pdfDocument = new Document(pdfStream);
for (int pageCount = 1; pageCount <= 4 && pageCount <= pdfDocument.Pages.Count; pageCount++)
Stream imageStream = new FileStream(pdfFileName + “.” + pageCount + “.png”, FileMode.CreateNew, FileAccess.Write);
JpegDevice jpegDevice = new JpegDevice((int)(pdfDocument.Pages.MediaBox.Width + pdfDocument.Pages.PageInfo.Margin.Left + pdfDocument.Pages.PageInfo.Margin.Right), (int)(pdfDocument.Pages.MediaBox.Height + pdfDocument.Pages.PageInfo.Margin.Bottom + pdfDocument.Pages.PageInfo.Margin.Top), new Resolution(resolution), quality);
Note that there are 2 parameters we could adjust: resolution and quality and here are some testing result:
1. resolution: 94, quality: 70, generated png for one page file pixel size: 792 * 936, png file size: 155.9 KB
2. resolution: 94, quality: 100, generated png file for one page pixel size: 792 * 936, png file size: 468.8 KB
3. resolution: 94*16, quality: 100, generated png file for one page pixel size: 792 * 936, png file size: 468.8 KB
So basically quality would increase the file size, but not the file pixel size and it generally improve the image quality as well, however it doesn’t seem to have an effect on this PDF file.
I know that this is related with original PDF file as well, its font is with small size and light color, however with zoom 130%, it is readable at Adobe Reader, however the generated image is not readable at all no matter how I zoom it in, basically it is blurred. I could give the original PDF file if required. Any idea how we can generate a high quality image here? If so, how we could adapt this at our code to basically use different parameter for different PDF files?
The Aspose.pdf version we are using is: 22.214.171.124.
Thanks very much for your help.