Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

real poor image quality after conversion from PDF

$
0
0
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:

namespace AsposeTester
{
    class Program
    {
        static void Main(string[] args)
        {
            string pdfFileName = @"<file path>\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[1].MediaBox.Width + pdfDocument.Pages[1].PageInfo.Margin.Left + pdfDocument.Pages[1].PageInfo.Margin.Right), (int)(pdfDocument.Pages[1].MediaBox.Height + pdfDocument.Pages[1].PageInfo.Margin.Bottom + pdfDocument.Pages[1].PageInfo.Margin.Top), new Resolution(resolution), quality);
                    jpegDevice.Process(pdfDocument.Pages[pageCount], imageStream);
                    imageStream.Close();
                }
            }
        }
    }
}

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. 

Resolution does not seem have any effect which seems by design from this post in forum: http://www.aspose.com/community/forums/permalink/530148/530148/showthread.aspx#530148

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: 8.9.0.0.

Thanks very much for your help. 


Viewing all articles
Browse latest Browse all 3131

Trending Articles