Reporting issue : images loose their aspect ratio

Hi

When using an image in a report template you need to specify a parameter format like ${imageFileId:widthxheight}

Problem is that the image will systematically and blindly resized to widthxheight, hence changing the aspect ratio of the original image. And there is no workaround to my knowledge, e.g pre-sizing the image beforehand won’t work.

A boolean parameter/configuration ‘keep aspect ratio’ somewhere would have made quite a sense.

In our case, the image depends on client & doc type, so we need to compute & change the widhtxheight manually for each client and each document, this is not very scalable…

As I already reported here, as reporting API users, we should really be able to extend the reporting logic in some way (e.g through spring beans), because this is a behavior one could (and likely would) override.

In that case, I would have overriden the corresponding ContentInliner and that would be done.

Michael

Hi

Sorry to bump here, is it possible to create 2 issues:

  • allow keeping aspect ratio on report images
  • make reporting implementation extendable through Spring beans

And if someone has a programmatic workaround for the 1st point, that would be welcome.

Regards
Michael

Hi,

allow keeping aspect ratio on report images

We have fixed one problem with image resize. Incorrect images resize with ${imageFileId:WxH} in DOCX · Issue #99 · cuba-platform/reports · GitHub. Perhaps, this fix resolves your problem. Could you provide sample project with incorrect resize?

make reporting implementation extendable through Spring beans

You can create own FormatterFactory implementation.
Register it in the spring.xml of core module:

<bean id="reporting_lib_FormatterFactory"
          class="com.haulmont.reports.libintegration.YourFormatterFactory">
        <property name="useOfficeForDocumentConversion" value="${reporting.openoffice.docx.useOfficeForDocumentConversion?:false}"/>
        <property name="officeIntegration" ref="reporting_lib_OfficeIntegration"/>
        <property name="defaultFormatProvider" ref="reporting_lib_CubaFieldFormatProvider"/>
</bean>

And override method createFormatter as:

 @Override
 public ReportFormatter createFormatter(FormatterFactoryInput factoryInput) {
        ReportFormatter formatter = super.createFormatter(factoryInput);
        if (formatter instanceof AbstractFormatter) {
            AbstractFormatter abstractFormatter = (AbstractFormatter) formatter;
            abstractFormatter.getContentInliners().add(new YourContentInliner());
        }
        return formatter;
 }

We’ll simplify the creation content inliners. See issue: Simplify creation of new content inliners · Issue #93 · cuba-platform/yarg · GitHub

Thank you,
Andrey