ngs-doo / TemplaterExamples

Creating reports in .NET and Java
https://templater.info
The Unlicense
48 stars 27 forks source link

Image maxSize #33

Closed LaurelJay closed 3 years ago

LaurelJay commented 3 years ago

Image MaxSize is not working on Excel document. How can we maintain Aspect ratio?

zapov commented 3 years ago

I'm not sure what you mean by not working in Excel. Please send a reproducible if its not working. But I'm quite sure it should be working fine.

I'm assuming you are using Java and having problems with Java image API. In which case you can use ImageInfo class from Templater directly and specify expected parameters there.

LaurelJay commented 3 years ago

I'm using C# , and my model has [DataMember] public virtual byte[] LogoReport { get { return _logoReport; } set { SetProperty(ref _logoReport, value, "LogoReport"); } }

    [DataMember]
    public virtual Image LogoReportImg
    {
        get
        {
            if (LogoReport == null)
            {
                return null;
            }
            else
            {
                using (var ms = new MemoryStream(LogoReport))
                {
                    return Image.FromStream(ms);
                }
            }
        }
    }

Then we are binding using [[comp.LogoReportImg]:maxSize(15, 20)] , The image is displaying but the maxSize has no effect. The provided example is on Microsoft Word, and I try it using Microsoft Excel.

zapov commented 3 years ago

Its hard to know why without you providing example which we can run. If I had to guess, I would say you didn't register the plugin during initialization: https://github.com/ngs-doo/TemplaterExamples/blob/master/Intermediate/Pictures/src/Program.cs#L118

LaurelJay commented 3 years ago

Ok, I did'nt know I have to add that Plug-in thanks..