HTML to PDF - Data URI

Images are not rendering properly when a PDF is generated. I am getting a x’ed out dead image where the proper image should be. Here is a simple test scenario I’ve been running that is not working, the text and the break show up just fine, but there is just a dead image showing up, instead of the intended one.


Testing Images
<img src=“data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA
AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
9TXL0Y4OHwAAAABJRU5ErkJggg==”>

And here is the full code I’m using that includes that block:

Section sec2 = new Section(pdf1);
pdf1.Sections.Add(sec2);
String img_test = “Testing Images
<img src=“data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==” alt=“Red dot”>”;
Text image_text = new Text(img_test);
image_text.IsHtmlTagSupported = true;
sec2.Paragraphs.Add(image_text);



I have created a work around for the time being which converts the data uri into a MemoryStream which can then be used by your tools to construct the image.

Hi Philip,

Thanks for using our products and sharing the sample source code with us.

I tested the scenario with your provided source code and able to notice the same problem but when I tried to access the image after saving source (Testing Images
\"Red) in a html file. The image is also not accessible directly. Kindly provide the exact image source path so that we can test the scenario at our end.

We apologize for your inconvenience.

Thanks & Regards,

The block of code you have pasted into the html file is character escaped as it was in the .cs file. Try running this block of code as just HTML and you will see the image:


Testing Images
Red dot

The sample was lifted from this wikipedia entry’s HTML Example section: http://en.wikipedia.org/wiki/Data_URI_scheme

Hi Philip,

Thanks for sharing the HTML source. I tested the scenario and able to notice the same problem. For rectification, I logged this problem with ID: PDFNEWNET-33824 in our Issue Tracking System. We will further look into the details of this issue and will keep you updated via this forum thread on the status of correction.

We apologize for your inconvenience.

Thanks & Regards,

The issues you have found earlier (filed as PDFNEWNET-33824) have been fixed in Aspose.Pdf for .NET 7.7.0.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.