We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problems Adding Image to PDF

Hi,

I've followed the documentation in an attempt to add images to a PDF file, but all I get is a blank document in the browser, my code as per the samples in the documentation is as follows:

Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();

Aspose.Pdf.Section section = new Aspose.Pdf.Section(pdf);

Aspose.Pdf.Image pdfImage = new Aspose.Pdf.Image(section);

section.Paragraphs.Add(pdfImage);

pdfImage.ImageInfo.ImageFileType = Aspose.Pdf.ImageFileType.Gif;

pdfImage.ImageInfo.File = "http://i.microsoft.com/global/en/publishingimages/sitebrand/microsoft.gif";

pdfImage.ImageScale = 0.5F;

pdf.Save("test.pdf", Aspose.Pdf.SaveType.OpenInBrowser, Response);

Any help would be appeciated as I am evaluating the product for an urgent software release.

Thanks

Tom

Hello Tom,

I have tested the scenario and I’m able to reproduce the same problem. For the sake of correction, I have logged it in our issue tracking system as PDFNET-18268. We will investigate this issue in details and will keep you updated on the status of a correction. <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

We apologize for your inconvenience.

Hello Tom,

After looking into the details of this problem, we have figured out that you are not adding the section containing image object to sections collection of PDF document. Please add the following code line to resolve this problem. The resultant PDF that I have generated using Aspose.Pdf for .NET 4.5.0 is also in attachment, please take a look.

pdf.Sections.Add(section);

In case it does not resolve your problem or you have any further query, please feel free to contact. We apologize for your inconvenience.