Open MovGP0 opened 5 years ago
Project was compiled as .NET Core 2.2
The image is embedded as BASE64 and still not working. Code is as follows:
// cell is of type MigraDoc.DocumentObjectModel.Tables.Cell
// imageBytes is of type byte[]
if (imageBytes == null || imageBytes.Length == 0) return;
var imageBase64 = "base64:" + Convert.ToBase64String(imageBytes);
cell.AddImage(imageBase64);
BASE64 images are supported starting with version MigraDoc v1.50.
For many reasons, we refused to use MigraDoc. Now we use SharpLayout. SharpLayout supports images from any stream:
cell.Add(new Image().Content(GetStream));
Stream GetStream()
{
return //Any Stream. For example, File.OpenRead, Assembly.GetManifestResourceStream, MemoryStream.
}
my workaround was to use the source of PDFSharpCore, did some code fixes on the release build, and used ImageSharp to load the file instead of the base64 encoded string.
Not a clean solution, because I now have rendering issues with tables and fonts. But at least the images are working.
When rendering an image to an PDF, I get the following exception: