oldrev / maltreport

A WYSIWYG document template engine to generates .odt/.ods/docx/xlsx/doc/xls documents for .NET
MIT License
125 stars 27 forks source link

Image Render #18

Open azacchino opened 6 years ago

azacchino commented 6 years ago

Hello, I tried to create a document (odt) with an embedded image. In the image, just replace the name with "$var". When you try to replace it with the context, the file is broken. How do I associate the image I want to replace with the context?

Using NuGet Version ( 2.1.1 )


System.IO.MemoryStream ms = new MemoryStream();
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
ms.GetBuffer();
Image im = new Image("png", ms.GetBuffer());

var renderContext = new Dictionary<string, object>()
{
       { "var", im },
}

OdfTemplate a = new OdfTemplate();
a.Load(path);
a.Compile();
IDocument b = a.Render(renderContext);
b.Save(@"C:\temp\simpleImageMap.ods");

Regargs

oldrev commented 6 years ago

Hello:

Sorry for the late response. Image rendering with MaltReport 2.1.1 has some serious issues, please try 3.x preview, it's stable enough to works with ODT/ODS.

MaltReport 3.x supports .NET FX 4.6 and .NET Core both.

Please see the HelloWorld project as an image-rendering sample in in the source repository.

azacchino commented 6 years ago

Hi! Thanks for the response. The 3.x branch hasn't tag. ¿the master branch is the 3.x?

oldrev commented 6 years ago

Yes, the master branch is 3.x, or you can install lib from nuget: https://www.nuget.org/packages/MaltReport2/3.0.0-beta-7