This project is read-only.

Encountered unexpected exception while fetching image from exception

Jul 27, 2014 at 12:19 PM
I have a fo block with an embedded image. but while running the code i am getting exception like this

my fo block

<fo:external-graphic src="url('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/')"/>

Exception I am getting

System.SystemException: Error while creating area : Encountered unexpected exception while fetching image from data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYE.../imagedata/
The URI prefix is not recognized.
at Fonet.FonetDriver.FireFonetError(String message)
at Fonet.Fo.Flow.ExternalGraphic.Layout(Area area)
at Fonet.Fo.FObjMixed.Layout(Area area)
at Fonet.Fo.Flow.Block.Layout(Area area)
at Fonet.Fo.Flow.Block.Layout(Area area)
at Fonet.Fo.Flow.Flow.Layout(Area area, Region region)
at Fonet.Fo.Flow.Flow.Layout(Area area)
at Fonet.Fo.Pagination.PageSequence.Format(AreaTree areaTree)
at Fonet.StreamRenderer.Render(PageSequence pageSequence)
at Fonet.Fo.FOTreeBuilder.EndElement()
at Fonet.Fo.FOTreeBuilder.Parse(XmlReader reader)

Ho to solve this? how i can embed an image using FO.NET?
Mar 30, 2016 at 2:37 PM
I am new in this forum, but would be very happy if anyone has found a solution to this issue, as I am facing the exact same.
Mar 31, 2016 at 10:46 AM
I anyone else finds this discussion I have found an answer.
FO.NET does not support this out of the box, but can be handled by writing our own image handler for the FonetDriver:

//add our own imageHandler
        var driver = FonetDriver.Make();
        driver.ImageHandler = ImageHandler;
        driver.Render(foReader, pdfStream);
//the ImageHandler, takes base64 encoded image data (i.e. without the prefix part data:image/jpeg;base64,)
    private static byte[] ImageHandler(string imageString)
        return Convert.FromBase64String(imageString);