format the text style in text field iReport - jasper-reports

I want to make some text in a text field bold. I visited http://jasperreports.sourceforge.net/sample.reference/markup/index.html but could not get the desired result. I am using text field right now but when I tried using styled/html, the compilation failed. So can you help me with this jrxml code snippet:
<textField>
<reportElement x="200" y="10" width="590" height="42"/>
<textElement markup="styled"/>
<textFieldExpression><![CDATA["The static text without any format.\nThe field's data with bold format<style isBold='true'>:" + $F{TASKS_SUBTASK} + "</style>\n<style isBold='true' isItalic='true' isUnderline='true'>The static underlined text with bold and italic format</style>"]]></textFieldExpression>
</textField>
In this example: Style a text field in Jasper, the text field expression is wrong for which compilation fails.
Your help will be appreciated.

This work good:
"<style isBold='true' pdfFontName='Helvetica-Bold'>" + $F{data} + "</style>"
for input data from datasource, or
<style isBold="true" pdfFontName="Helvetica-Bold">Bolt text</style>
only for some static text.
For Text-field set properties Markup = styled.

in your view ireport designer.
click on the field and in the properties panel.: markup = styled selected
Right click on the fied. edit expression:
($F{fila1}.equals("c") ? "<style forecolor='red'>"+ $F{fila1}+"</style>" : $F{fila1})
or xml
<textFieldExpression><![CDATA[($F{fila1}.equals("c") ? "<style forecolor='red'>"+ $F{fila1}+"</style>" : $F{fila1})]]></textFieldExpression>

The <b> </b> tags no longer work on text fields. Make sure that 'Styled text' is enabled for the text field and put this in the field expression.
<style isBold="true" pdfFontName="Helvetica-Bold">Text to be bold...</style>
The pdfFontName can be whatever you like.
If you are making text bold that is already in a string be sure to escape the above quotes with a backslash.

I solved by putting for bold and underline in input string
"<b><u> your text</u></b>"

I solved this problem changing 'makup' text-field atribute to 'html'. Then in text-field expression use html tags like < b> < /b>. =D

"<style isBold='true' pdfFontName='Helvetica-Bold'>" + $F{data} + "</style>"
what is done above simply
<style isBold="true" pdfFontName="Helvetica-Bold">Bolt text</style>
For Text-field set properties Markup = styled.
see the screenshot below
hope this helps !!!

Related

MUI Multiline event.target.value not showing \n

I currently have a multiline text box and whenever a new line is created via the website, it's not reflected in the backend with a \n.
The goal is to have each new line equate to a \n whenever the event.target.value is called.
`
const [welcomeText, setwelcomeText] = React.useState(welcome.welcomeText);
const handleWelcomeTextChange = (event) => {
setwelcomeText(event.target.value);
};
`
`
<TextField
id="outlined-multiline-flexible"
label="Welcome Text Description"
multiline
fullWidth
maxRows={10}
value={welcomeText}
defaultValue={welcome.welcomeText}
onChange={handleWelcomeTextChange}
/>
`
I've tried to implement a fix to detect spacing and convert it to a \n however this didn't work.
you can actually use the add a style prop to the typography component
<Typography style={{ whiteSpace: 'pre-line' }}>{'hello \nMUI'}</Typography>
I spent almost an hour looking for the solutions to that stupid \n too.
Hope it helps.

DYMO print label text getting cut off

I am trying to print Address label on dymo labelwriter 450 turbo
But the text is getting cutoff
I am using the below xml to format the text
function getAddressLabelXml()
{
var labelXml = '<?xml version="1.0" encoding="utf-8"?>\
<DieCutLabel Version="8.0" Units="twips">\
<PaperOrientation>Landscape</PaperOrientation>\
<Id>Address</Id>\
<PaperName>30252 Address</PaperName>\
<DrawCommands>\
<RoundRectangle X="0" Y="0" Width="1581" Height="5040" Rx="270" Ry="270" />\
</DrawCommands>\
<ObjectInfo>\
<AddressObject>\
<Name>Address</Name>\
<ForeColor Alpha="255" Red="0" Green="0" Blue="0" />\
<BackColor Alpha="0" Red="255" Green="255" Blue="255" />\
<LinkedObjectName></LinkedObjectName>\
<Rotation>Rotation0</Rotation>\
<IsMirrored>False</IsMirrored>\
<IsVariable>True</IsVariable>\
<HorizontalAlignment>Left</HorizontalAlignment>\
<VerticalAlignment>Middle</VerticalAlignment>\
<TextFitMode>ShrinkToFit</TextFitMode>\
<UseFullFontHeight>True</UseFullFontHeight>\
<Verticalized>False</Verticalized>\
<StyledText/>\
<ShowBarcodeFor9DigitZipOnly>False</ShowBarcodeFor9DigitZipOnly>\
<BarcodePosition>BelowAddress</BarcodePosition>\
<LineFonts/>\
</AddressObject>\
<Bounds X="332" Y="150" Width="4455" Height="1260" />\
</ObjectInfo>\
</DieCutLabel>';
return labelXml;
}
Depending on the length and height of the text, the text is either getting cutoff on the top or on the right
I am looking for a way to auto fit the text inside the label
Thanks in advance.
Change the TextFitMode value from 'ShrinkToFit' to 'AlwaysFit'

How to create dynamic color for text field?

Background: Jaspersoft studio 6.2
How to change forecolor of a text field based on an expression.
How can I apply a expression so the font color (forecolor) will be based on the value in that field? I can't find anywhere to set a expression for the forecolor property.
Maybe there is an option:
You need to set markup to style.
And then use an expression in the text field:
F{value1}=="GREEN"?$F{value1}:"<style backcolor='red'>"+$F{value1}+"</style>"
You can also add conditions and set multiple colors:
F{value1}=="GREEN"?"<style backcolor='green'>"+$F{value1}+"</style>":"<style backcolor='red'>"+$F{value1}+"</style>"
Maybe this will work for you.
Another possibility would be to use a style property expression in your textfield:
<textField ...>
<reportElement ...>
<propertyExpression name="net.sf.jasperreports.style.forecolor">
<![CDATA["#00FF00"]]>
</propertyExpression>
</reportElement>
...
</textField>
This setting will override the current forecolor attribute for the textfield, and a green text will be printed out.
Here are listed all dynamic style properties available for report elements.
You use conditionalStyle, to achieve this
Example
<style name="myStyle" forecolor="#0000FF">
<conditionalStyle>
<conditionExpression><![CDATA[$F{myField}<0]]></conditionExpression>
<style forecolor="#CC0000"/>
</conditionalStyle>
</style>
Then set the style to the textField when you like to use it
<textField>
<reportElement style="myStyle" x="448" y="5" width="100" height="20" uuid="b75e4497-e952-4051-8640-2f6b498dd152"/>
<textFieldExpression><![CDATA["Hello world"]]></textFieldExpression>
</textField>
In JasperSoft Studio, right click on style in outline to create "Conditional Style" and set the properties in the properties tab

How to get the baseURL in a Typo3 template

I defined with typoscript the baseURL with the following code:
page.config.baseURL = http://www.website.nl/
Now I want to use the baseURL in the html template for a reference to a image. How can I add this url to the template? Tried the following but is not working.
<img src="{baseURL}images/sicma.png" width="70" height="28" alt="sicma">
Put it into a constant first:
baseURL = http://www.website.nl/
then use it in setup
page.config.baseURL = {$baseURL}
temp.logo = TEXT
temp.logo.value = <img src="{$baseURL}images/sicma.png" width="70" height="28" alt="sicma">
Of course, you have to assign temp.logo to the template.
But isn't baseURL precisely there so you don't have to write absolute paths?

How to create an SVG "tooltip"-like box?

Given an existing valid SVG document, what's the best way to create "informational popups", so that when you hover or click on certain elements (let's say ) you popup a box with an arbitrary amount (i.e. not just a single line tooltip) of extra information?
This should display correctly at least in Firefox and be invisible if the image was rasterized to a bitmap format.
This question was asked in 2008. SVG has improved rapidly in the intervening four years. Now tooltips are fully supported in all platforms I'm aware of. Use a <title> tag (not an attribute) and you will get a native tooltip.
Here are the docs:
https://developer.mozilla.org/en-US/docs/SVG/Element/title
<svg>
<text id="thingyouhoverover" x="50" y="35" font-size="14">Mouse over me!</text>
<text id="thepopup" x="250" y="100" font-size="30" fill="black" visibility="hidden">Change me
<set attributeName="visibility" from="hidden" to="visible" begin="thingyouhoverover.mouseover" end="thingyouhoverover.mouseout"/>
</text>
</svg>
Further explanation can be found here.
Since the <set> element doesn't work with Firefox 3, I think you have to use ECMAScript.
If you add the following script element into your SVG:
<script type="text/ecmascript"> <![CDATA[
function init(evt) {
if ( window.svgDocument == null ) {
// Define SGV
svgDocument = evt.target.ownerDocument;
}
tooltip = svgDocument.getElementById('tooltip');
}
function ShowTooltip(evt) {
// Put tooltip in the right position, change the text and make it visible
tooltip.setAttributeNS(null,"x",evt.clientX+10);
tooltip.setAttributeNS(null,"y",evt.clientY+30);
tooltip.firstChild.data = evt.target.getAttributeNS(null,"mouseovertext");
tooltip.setAttributeNS(null,"visibility","visible");
}
function HideTooltip(evt) {
tooltip.setAttributeNS(null,"visibility","hidden");
}
]]></script>
You need to add onload="init(evt)" into the SVG element to call the init() function.
Then, to the end of the SVG, add the tooltip text:
<text id="tooltip" x="0" y="0" visibility="hidden">Tooltip</text>
Finally, to each of the element that you want to have the mouseover function add:
onmousemove="ShowTooltip(evt)"
onmouseout="HideTooltip(evt)"
mouseovertext="Whatever text you want to show"
I've written a more detailed explanation with improved functionality at http://www.petercollingridge.co.uk/interactive-svg-components/tooltip
I haven't yet included multi-line tooltips, which would require multiple <tspan> elements and manual word wrapping.
This should work:
nodeEnter.append("svg:element")
.style("fill", function(d) { return d._children ? "lightsteelblue" : "#fff"; })
.append("svg:title")
.text(function(d) {return d.Name+"\n"+d.Age+"\n"+d.Dept;}); // It shows the tool tip box with item [Name,Age,Dept] and upend to the svg dynamicaly