Images appearing too small in generated documents

Hi,

I am having this issue… larger images display nicely on the pdf, but images that are smaller (e.g. 100 px width) are appearing really really small.

The code I am using is below:

'create pdf and set up pdf margins etc

Dim _pdf As Pdf = New Pdf()
Dim lic As Aspose.Pdf.License = New Aspose.Pdf.License
Try
lic.SetLicense(Server.MapPath("lics/") & "Aspose.Pdf.lic")
Catch ex As Exception
System.Diagnostics.Debug.WriteLine(ex.ToString)
End Try

With _pdf
.PageSetup.Margin.Left = 20
.PageSetup.Margin.Top = 20
.PageSetup.Margin.Right = 20
.PageSetup.Margin.Bottom = 20
.CompressionLevel = 9
End With

....and to generate the image and place inside table cell:

Dim img As Aspose.Pdf.Image = New Aspose.Pdf.Image(_sc)
img.ImageInfo.ImageFileType = ImageFileType.Jpeg
img.ImageInfo.ImageStream = Me.GetIMGStream(dr("Clip_URL").ToString)
img.ImageInfo.DefaultFile = http://www.intelligentmedia.com/img/NotAvailable.gif
_rw.Cells(0).Paragraphs.Add(img)

I am attaching the resulting PDF from the above code and also the original image (the size it actually is).

As you can see the PDF image is too small. This only ocurrs with smaller images, larger ones are fine.

Also, I have attached a larger image with the corresponding PDF which was created (just to show you how the larger images display ok). For images that are too big to fit on the PDF, I am using a custom class to resize them.

Please can you advise on how to resolve this.

Thanks.

Hello <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />Gary,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for considering Aspose.

Please try using the Image.ImageScale property of Image class, to specify the scale rate of the image, when placed into the Pdf file. Please add the following code line, after you have created an object of Image class.

img.ImageScale = 2.0F

If it does not resolve the problem, please feel free to contact.

Hello,

Thanks for your response.

The images I am loading into the PDF have varying sizes and I need to resize them accordingly. Before loading them into the PDF I am ensuring that the dimensions of the image can fit on to the page.

Since the Aspose image properties "ImageWidth" and "ImageHeight" do not return any values, it is impossible for me to determine when an image should be scaled and when it should not be.

But my question is (as you can see from the attachements) - why is the Kerrang image so small when inserted into the pdf.

What is the pixel resolution of the PDF document?

The component works just fine otherwise, but without resolving this issue there is no way I can roll this out to our client site.

If there is any other solution then please advise.

thanks.

Hi,

The default resolution for image is 300 PPI. You can use System.Drawing.Bitmap to get the image size and decide if you need to set the scale parameter. You can also use the ImageInfo.FixWidth to set the image with to fit the page width.

Hi,

Thats all fine, but I should not need to scale this image (e.g. the attached Kerrang image).

Why is it shrinking so much when placed in the PDF?

thx.

Hi,

I don't think the image is shriking. As I mentioned in the previous post, the default resolution is 300 PPI. So the size of the image in PDF is:

image size in pixel size in inch
--------------------------------------------------------------
Kerrang.jpg 100 * 297 0.33 * 0.99
LondonPaper.jpg 788 * 834 2.63 * 2.78

Hi Tommy,

Thanks for you reply.

The images are also 300dpi so I am just confused as to why they appear so small on the PDF.

I will have to see what kind of work around can be done.

thanks.

Hi,

Is there a built in command to resize images in pdfs, back to the size of how they look on paper?

thanks.

Hello Gary,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

The query has been replied over 191000. Please take a look and in case of any further information, feel free to contact.