Can svg clip-path property be used on tspan element - dom

Even after a lot of search I can't find any mention of this over the net. And When I tried to use clip-path on a tspan element, it didn't work for me. Am I doing something wrong or clip-path doesn't work for tspan elements that are nested inside a text element?
This is my svg code I am trying.
<svg width="500px" height="500px">
<defs>
<clipPath id="clipPath841">
<rect width="10" y="0" x="0" height="100%"></rect>
</clipPath>
</defs>
<text y="130" x="125" __internalID="internal281">
<tspan textLength="30" clip-path="url(#clipPath841)">
Hello world how are you what are you doing
</tspan>
</text>
</svg>

Per the SVG 1.1 specification you cannot set a clipPath on a tspan.
Applies to: container elements, graphics elements and ‘clipPath’
And tspan is not a graphics element.
The upcoming SVG 2 specification may change this.

Related

Subreports with alternating backgrounds

I'm using iReport 3.7.6. (with no possibility of using a newer version).
I have a main report and a subreport. Subreport repeats multiple times and I need to set alternating background to subreports, but I need to show subreports one below each other so that they split when the new page starts, not showing them on page only if they fit.
This is what I want:
I tried multiple things but I cannot seem to get it to work.
I tried using frame and setting alternate row style and putting all the elements in that frame:
<style name="AlternateRowStyle" mode="Opaque">
<conditionalStyle>
<conditionExpression><![CDATA[$V{REPORT_COUNT} % 2 == 0]]></conditionExpression>
<style backcolor="#E5E7E9"/>
</conditionalStyle>
</style>
but I get results like in this post: Splitting a band's background frame
Then I tried using background band (for simplicity, I just added frame with one color, so no alternation) but I have experienced difficulties in this approach too.
My subreport has only Detail and Background band to which I've set equal height and split type immediate.
Main report only has detail band (I simplified it).
Subreport snippet:
<background>
<band height="250" splitType="Immediate">
<frame>
<reportElement mode="Opaque" x="0" y="0" width="600" height="250" backcolor="#E5E7E9"/>
</frame>
</band>
</background>
<detail>
<band height="250" splitType="Immediate">
//content not important
</band>
</detail>
Main report snippet:
<detail>
<band height="660" splitType="Immediate">
<subreport>
<reportElement positionType="Float" x="0" y="0" width="600" height="250"/>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{objects})]]></dataSourceExpression>
<subreportExpression class="java.lang.String"><![CDATA[$P{SUBREPORT_DIR} + "subreport1.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
But this approach results in wierd behaviour: Background from subreport shows on each page of main report only once and only at the beginning of the page, no matter how many subreports are actually on one page of main report, like background is set to main report (shown on picture). I would like each report to have the background.
I'd appreciate any help.

How to increase height of 'band' element if the value in 'textFieldExpression' has greater height than the height specified in "band height"?

My detail element is as follows:-
<detail>
<band height="22" splitType="Stretch">
<textField isStretchWithOverflow="true">
<reportElement uuid="a59a8d47-59cb-490e-953d-d4b1e2af52c0" x="0" y="0" width="191" height="20"/>
<box leftPadding="5" rightPadding="5"/>
<textElement verticalAlignment="Middle">
<font fontName="ARIALUNI" size="10" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{key}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement uuid="09798815-2a54-42db-963a-3f443a5fc1c2" x="191" y="0" width="500" height="20"/>
<box leftPadding="5" rightPadding="5"/>
<textElement verticalAlignment="Middle">
<font fontName="ARIALUNI" size="10" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{value}]]></textFieldExpression>
</textField>
</band>
</detail>
If I set band height="30", then the value of second correctly overflows but at same time extra white space is visible for rows where there is no overflow. With band height="22", no extra whitespace and also no overflows (which is a requirement). So can the height of band be set dynamically so that height increases when overflow takes place, otherwise it (height) maintains a low value (without extra-space).
This already happens automatically. If a band contains content that stretches, it will also stretch to accommodate that content. Or, as the JasperReports Ultimate Guide puts it:
"When stretchable text fields are present on a report section, the height of the report section
itself is affected by the stretch."
This makes sense when you think about when the report is filled. Theoretically you could always pass longer and longer data, making the text field stretch further and further. If the band height had to be set manually to accommodate this, you would be forever updating the design.
So what's the solution? Easy: Design everything at the minimum height, set fields to stretch if they need to, and don't worry about the band height.
What about the white space?
The white space you're seeing is probably due to the way space in the design is preserved at the end of a band. With your example, the band height is 22 pixels, but the content only fills a height of 20 pixels, leaving a 2 pixel row of white space at the bottom of the band. When you increase the band height to 30 pixels, without increasing the size of the content (I'm assuming this is the case), you will have created 10 pixels of white space.
The white space you leave in you design will be included in the filled report, repeated for each instance of the band and still included if the content stretches. So after your text field stretches to be 30 pixels tall, the band will stretch to 40 pixels to preserve the 10 pixels of white space.

How to draw vertical line in iReport?

I am using iReport 3.5.2? to design a report. I have a subreport where I need to have a table.
To build the table I have drawn horizontal lines for rows. However I am not finding any option to make the line vertical so that I can make the columns.
Could anyone please suggest how to do it.
You can make your line Vertical of Horizontal as you like
By changing width and height properties of the line
For example
If you want to draw a Vertical Line
<line>
<reportElement x="0" y="0" width="1" height="30"/>
</line>
If you want to draw a Horizontal Line
<line>
<reportElement x="0" y="0" width="30" height="1"/>
</line>
line is bad decision, may be problems on page ending/begining
use
<style name="cell">
<box>
<pen lineWidth="1.0" lineStyle="Solid"/>
</box>
</style>
for your textField/staticText
Select line properties.Set width=1 ,height=value greater than 1

JasperReports text field stretching - can stretch height be limited?

I've got the following problem with a JasperReports subreport that I've been trying to solve for the past couple of days with no success. Below is an image of what I'm trying to do.
I've got a subreport in one of my reports that is relatively simple. Its got a title band with a single text field (marked brown in the image) for the subreport title and a detail band with two items: a subreport (marked blue in the image) printing my line items and a text field (marked red in the image) printing the comments associated with the line items printed to the left of it. The line item subreport can print a variable number of line items (datasource backed by a bean collection). My customers requirement is that the comments field stretches and shows the text entered, but be limited by the height of the line item section (represented by the arrows on the image). I somehow need to prevent the comments from stretching beyond the line items and make them of equal height (there should be no green box in the image).
Does anyone have any tips how this could be (and can it at all be) achieved in JasperReports?
p.s.
We are currently compiling our reports with JR version 3.6
Put both the subreport and the text field into a frame. For the text field, set "Stretch with overflow" to false and "Stretch type" to "Relative to tallest object"
The text field will stretch relative to the tallest object in it's container. It's container is now the frame, so the "tallest object" can only be the subreport. Make sure the elements are the same height when you define them, otherwise they will grow at different rates.
JRXML sample:
<band height="50">
<frame>
<reportElement x="0" y="0" width="555" height="50"/>
<subreport>
<reportElement x="0" y="0" width="378" height="50"/>
...
</subreport>
<textField isStretchWithOverflow="false">
<reportElement stretchType="RelativeToTallestObject" x="378" y="0" width="177" height="50"/>
...
</textField>
</frame>
</band>

JasperReports: does positionType=''Float'' work at all for staticText?

I need to have a staticText to float below another element with variable height. I'm taking a sample from the book JasperReports for Java Programmers. It says that it's possible to do it. The difference with my sample is that I use a hard coded string in textFieldExpression, they use a $F{} field.
<textField isStretchWithOverflow="true" hyperlinkType="None">
<reportElement x="0" y="0" width="100" height="24"/>
<box>
<pen lineWidth="0.5" lineStyle="Solid"/>
</box>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA["jjjjjjjjjjj oooooooooo uuuuuuuuuu aaaaaaaaaa xxxxxxxxx u ttttt"]]></textFieldExpression>
</textField>
<staticText>
<reportElement positionType="Float" x="0" y="25" width="500" height="30"/>
<box>
<pen lineWidth="0.5" lineStyle="Solid"/>
</box>
<textElement/>
<text><![CDATA[ This staticText element has a positionType of "Float" ppp ]]></text>
</staticText>
It says that when you use positionType="Float", the y attribute is ignored, because the staticText is positioned below the textField. This appears to work, BUT... is it possible they are BS'ing me? The textField has y=0 and height=24. The staticText has y=25. Coincidence? If I change the staticText's y, it is obvious that it isn't ignored: the element is positioned wherever I tell it to. There's no floating!!!
Quote from the book:
As we can see, setting the positionType attribute of <reportElement> to Float made JasperReports ignore the y position of the <staticText> element, which was pushed down by the stretched <textField> element.
No, we don't see how it is being ignored because y=25 is where we expected it!
Does positionType="Float" work for staticText at all?
Thanks!
My understanding of the floating nature is that the floating object will move down if necessary, but if the previous object is smaller than expected, it doesn't move up.
I don't recall having any problems with floating objects not actually floating down when necessary, whether they be static text or text fields.
On another note, if you find a text field works, you can use it to display static text by putting your text in quotes in the text field value (making it a Java object).
This answer applies (different elements, same situation).
One thing I didn't take right from the book's sample is that the textField's declared height (24) is less than the actual height when the element is stretched. So, y="25" on the staticText would map above its actual position; the element is actually floated down!