Troubles adding a png image to a PDF ASP.Net 1.1 (visual basic)


#1

I have searched everywhere and cannot find an example of adding a .png image to a PDF.

I am getting this error

Couldn't open image file: C:\WebTest\AsposePdfDemosVisualBasic\brandt.png

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ApplicationException: Couldn't open image file: C:\WebTest\AsposePdfDemosVisualBasic\brandt.png

The file is in the same folder as brandt.tiff which works. I read on another post about the possibility of permissions issues but have ensured that permissions are set correctly. The png file was set to 24 bit with transparency set to true.

Here is my code. This works!

Dim pdf1 As Pdf = New Pdf

Dim sec1 As Section = pdf1.Sections.Add()

Dim image1 As Aspose.Pdf.Image = New Aspose.Pdf.Image(sec1)

sec1.Paragraphs.Add(image1)

image1.ImageInfo.File = "C:\WebTest\AsposePdfDemosVisualBasic\brandt.tiff"

image1.ImageInfo.ImageFileType = ImageFileType.Tiff

Here is my code. This doesnt work!

Dim pdf1 As Pdf = New Pdf

Dim sec1 As Section = pdf1.Sections.Add()

Dim image1 As Aspose.Pdf.Image = New Aspose.Pdf.Image(sec1)

sec1.Paragraphs.Add(image1)

image1.ImageInfo.File = "C:\WebTest\AsposePdfDemosVisualBasic\brandt.png"

image1.ImageInfo.ImageFileType = ImageFileType.Png

I am confused as to why a png image causes an error.

Thanks for your help.

Tyler


#2

Dear Tyler,

Thank you for considering Aspose.

This is really strange. Can you please attach your PNG image here and let me test it?


#3

Here is the .PNG file you requested


#4

I have tested this issue and no error is found. Please make sure:

1) You are using the latest version of Aspose.Pdf.

2) The file path is correct.

3) The application has the permission to access the file.


#5

Thankyou very much for testing this and getting back to me so soon. I double checked and realized this was a permissions problem. Sorry for the oversight.

Tyler