We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

PDF Image resolution

I need to import a PNG into a PDF. The original PDF is quite big, approx 7000x8000px / 96 dpi, 4MB. I am using a A4 PDF page in order to do so.

The import works, but the resolution is not satisfactory. The client size (page.GetClientSize()) is 515/796. Including the margins this means 72dpi. Since I use the following code at least I do understand why the resolution in the PDF is poor.

page.Graphics.DrawImage(pdfImage, 0f, 0f, page.GetClientSize().Width, page.GetClientSize().Height);

But I should be able to put an image on a PDF document with a much higher resolution, e.g. 300 or 600 dpi. What I mean is that the screen resolution should not directly correspond 1:1 with the image size, since e.g. for printing the resolution will be much higher.

Q1: How would I set the resolution (dpi) for the PDF page in general. I have no idea where the 72dpi come from?

Q2: How could I generate an image with a much higher resolution but still have it on the page approx. 8,6” width?

As an approach I have also used EMF import, but this ends with an out of Memory exception. Most preferable I’d like to add a vector graphic, but the best source format I can generate is PNG.

As another crosscheck I have generated a similar one page PDF with Word / Adobe based on the same PNG, the PNG having the full resolution but fitting on the page.

Maybe someone can point out how I would do this with the PDFDocument classes. Any help is appreciated.


3 Replies

BP Bhuvaneswari P Syncfusion Team May 5, 2009 12:43 PM UTC

Hi Klaus,

Thanks for your inquiry.

1: How would I set the resolution (dpi) for the PDF page in general? I have no idea where the 72dpi come from?

Currently it’s not possible to set the resolution of the PDF page.

Q2: How could I generate an image with a much higher resolution but still have it on the page approx. 8,6” width?

It can be possible to set the image quality by using the Quality property of the image object. Please refers to the below code snippet:

For metafile Image
// Create metafile image
PdfMetafile metafile = (PdfMetafile)PdfImage.FromImage(img);
// Specify the quality of the metafile
metafile.Quality = 80;
//For bitmap sepcify the image quality
PdfBitmap image1 = new PdfBitmap(Image.FromFile("image.bmp"));
image1.Quality = 50;
page.Graphics.DrawImage( image1, new PointF( 0, 0 ));

Documentation link:
http://help.syncfusion.com/ug_72/pdf/DrawingImages.html

Please try this, if this not helps you. Please provide your image with expected output. This would helps to provide you the more details.

Best Regards,
Bhuvana



AD Administrator Syncfusion Team May 9, 2009 05:23 PM UTC

Thanks to your help I have managed to create an "acceptable" result with a PNG image as basis. However the EMF version (see the ZIP please) is much better when zooming in.

However, creation with EMF fails with memory issues. Maybe you could give me a hint how I would / could realize the EMF generation?

All relevant files are available, but I failed to upload them (due to size /6Meg?). Could I send you the files via mail?


BP Bhuvaneswari P Syncfusion Team May 11, 2009 01:18 PM UTC

Hi Klaus,

Could you please open a new direct – trac incident with subject line as Forum 80866- PDF Image resolution. Please send the sample in the direct trac incident. We will look into the sample and provide the possible solution.

Best Regards,
Bhuvana

Loader.
Live Chat Icon For mobile
Up arrow icon