I'm using MvcRazorToPdf in my Asp.net MVC5 project to create pdfs from model. That works fine, but I want to include an image from a base64 string, because I don't want to save the generated image.
System.Drawing.Image img = generator.GenerateImage();
string imageBase64Data = Convert.ToBase64String(Helper.ImageToByteArray(img));
string imageDataURL = string.Format("data:image/png;base64,{0}", imageBase64Data);
ViewBag.Image = imageDataURL;
return new PdfActionResult(myobject);
...
<img src="@ViewBag.Image" />
Working fine, if showing the image in a normal view, but the pdf doesn't show the image.
Thank you for help or alternatives.
In MvcRazorToPdf you can only use the full (local) path to the image file like this:
Base64 images are not supported as far as I know. I copied the snippet above from the example view at: https://github.com/andyhutch77/MvcRazorToPdf/blob/master/MvcRazorToPdfExample/Views/Pdf/Index.cshtml