QuilhaSoft / JasperPHP

Pure PHP library to read JRXML files made in "JasperSoft Studio" and generate reports in PDF/XLS
https://jasperphp.net
MIT License
63 stars 25 forks source link

Stretch overflowed fields not stretching it's band #22

Open allgood opened 4 years ago

allgood commented 4 years ago

On a report with two detail bands, the first one have a field that stretchs with its contents, the expected behavior is to move the following band down but it gets overwritten.

Looks like the stretched field isn't stretching its parent band

Image of sample is attached.

image

Rctnet commented 4 years ago

Try check if split type property is "stretch" ou "prevent" in both bands, when you be create bands in JasperSoft Studio, it´s create if split type property with null value

allgood commented 4 years ago

Hi,

I've checked this because bands where overlapping even without the field stretching.

Problem now is that the stretching field doesn't stretch it's parent band height.

Em 2 de março de 2020 14:35:32 BRT, Rogerio Muniz notifications@github.com escreveu:

Try check if split type property is "stretch" ou "prevent" in both bands, when you be create bands in JasperSoft Studio, it´s create if split type property with null value>

-- > You are receiving this because you authored the thread.> Reply to this email directly or view it on GitHub:> https://github.com/QuilhaSoft/JasperPHP/issues/22#issuecomment-593522525

-- E-mail enviado do meu celular Android usando K-9 Mail. Por favor, desculpe minha brevidade.

Rctnet commented 4 years ago

Hi, a few seconds ago post a possible solution, try update and test again.

Rctnet commented 4 years ago

remember to check stretch with overflow property in textfield

allgood commented 4 years ago

I'm having trouble on finding this property on Jasper Studio. Field is stretching only if I choose HTML, but there is no "Stretch with overflow" property here.

image

Rctnet commented 4 years ago

Here image

allgood commented 4 years ago

Doesn't show here! Don't know if it is because of any other option, tried with a blank report!

image

allgood commented 4 years ago

Looks like it is the textAdjust option on my version, it have CutText, StretchHeight (I'm choosing this), and ScaleFont options!

allgood commented 4 years ago

This is how the code ends on the xml:

<textField textAdjust="StretchHeight">
    <reportElement x="0" y="0" width="180" height="18" uuid="5e2f0d45-410f-4627-964a-8f2d311dde90"/>
    <textElement textAlignment="Left" verticalAlignment="Top" markup="html"/>
    <textFieldExpression><![CDATA[$F{text}]]></textFieldExpression>
</textField>
Rctnet commented 4 years ago

image ou

<textField isStretchWithOverflow="true">
                <reportElement x="2" y="4" width="547" height="11" isPrintWhenDetailOverflows="true" uuid="bceaac6a-262b-4b5d-a180-ec3751e5a755">
                    <printWhenExpression><![CDATA[$V{total_receb} > 0]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA["Recebemos do(a) Sr(a) "+$F{locatarios_nome}+" a importancia acima mencionada de R$"+$V{total_receb}.toString()+" ("+$V{total_receb}.numberToText()+" )"]]></textFieldExpression>
            </textField>

you can add isStretchWithOverflow ou isPrintWhenDetailOverflows, both be make stretch

allgood commented 4 years ago

Tool automatically changes edition of isStretchWithOverflow when saving... looks like the format is changed on my version.

Both with isPrintWhenDetailOverflows selected on jasperstudio and with isStretchWithOverflow added outside jasper studio the same problem happens.

Tomorrow I will try to make a proof of concept of the bug and post here.

allgood commented 4 years ago

Here is a proof of concept of the problem

https://drive.google.com/open?id=18M8PLgYcdLyzaz2lrhPxpf5XyTdJnJvh

allgood commented 4 years ago

@Rctnet ... found the problem here... I have marked HTML since it was the only way I was able to get all the content, correct is to use none instead.

Anyway, the problem still occurs for HTML.

And on a sidenote, looks like you are testing reportElement for isStretchWithOverflow when the correct is to test the TextField object ($this). You can also add the value that new version of JasperStudio uses. (I will submit a PR with this change in a few minutes).

Another thing is the isPrintWhenDetailOverflows... for me it haves a different meaning, like if the element should appear even if its contents extends the bounds of the parent element.

allgood commented 4 years ago

Still some issues.

On the image attached the "Descrição" field have the textAdjust="StretchHeight" parameter. The first field "Sequencia" ends being printed outside its box making the report confusing.

Will try to make another PoC later today so it can be debugged.

image

allgood commented 4 years ago

Had some satisfactory results changing the order of the fields on XML, every element placed after the stretching one gets its position affected. It doesn't respect the "relative to top" or "relative to bottom" property.

It is not optimal, but it will do what I need.

allgood commented 4 years ago

Just to keep this here:

any field declared AFTER a stretched field on the jrxml file gets its coordinates entirely unpredictable, so fields that are before or on the same line of it, or even fields that must have a fixed position must be declared before. all other fields will apply the offset of the stretched field... even if the field doesn't stretch.

I suppose it can be considered a bug because this is not the jasper reports behavior , but it is possible to work around it if only one field is stretchable and everything bellow it should move down. Things can get messy if two or more stretchable fields lies on the same page.