RTThomas Posted May 18, 2016 Share Posted May 18, 2016 I need to style parameter and field strings with an embedded font for my pdf document. Something like this: <textField> <reportElement isPrintRepeatedValues="false" x="115" y="85" width="210" height="21" uuid="7130cf53-a6c1-4d8a-89cf-86bb03a9fb00"> <property name="com.jaspersoft.studio.unit.width" value="pixel"/> </reportElement> <textElement markup="styled"> <paragraph leftIndent="5" spacingBefore="4"/> </textElement> <textFieldExpression><![CDATA[<style pdfFontName="TimesNewRoman" isPdfEmbedded="true">$F{name}</style>]]></textFieldExpression> </textField> But I get this when compiling: net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file: 1. Syntax error on token(s), misplaced construct(s) value = <style pdfFontName="TimesNewRoman" isPdfEmbedded="true">((java.lang.String)field_name.getValue())</style>; //$JR_EXPR_ID=10$ <-----> 2. Syntax error on token "<", delete this token value = <style pdfFontName="TimesNewRoman" isPdfEmbedded="true">((java.lang.String)field_name.getValue())</style>; //$JR_EXPR_ID=10$ ^ 3. style cannot be resolved to a type value = <style pdfFontName="TimesNewRoman" isPdfEmbedded="true">((java.lang.String)field_name.getValue())</style>; //$JR_EXPR_ID=10$ <---> Is there any way to do this? Thanks. Link to comment Share on other sites More sharing options...
hozawa Posted May 19, 2016 Share Posted May 19, 2016 pdfFontName is no longer supported. Use Use Font Extensions instead.http://community.jaspersoft.com/wiki/custom-font-font-extension Link to comment Share on other sites More sharing options...
RTThomas Posted May 19, 2016 Author Share Posted May 19, 2016 Hozawa, please stop making so many posts when you don't understand the question. I AM using a font extension, and reference the font in <style pdfFontName=....> It works fine. What do you mean "no longer supported?" For instance, this compiles, and the style shows up in the exported PDF:<staticText> <reportElement style="Normal" x="5" y="2" width="144" height="14" uuid="672eb87e-2fe1-4856-a595-d7a5f705e8f5"> <property name="com.jaspersoft.studio.unit.height" value="pixel"/> <property name="com.jaspersoft.studio.unit.y" value="pixel"/> </reportElement> <text><![CDATA[<style pdfFontName="TimesNewRoman" isPdfEmbedded="true">Temporary License Issue Date:</style>]]></text></staticText> The question is about applying such a font to style text produced by a field or parameter reference ($F{} or $P{}). For instance, the CDATA expression below will not compile: <textField> <reportElement isPrintRepeatedValues="false" x="115" y="85" width="210" height="21" uuid="7130cf53-a6c1-4d8a-89cf-86bb03a9fb00"> <property name="com.jaspersoft.studio.unit.width" value="pixel"/> </reportElement> <textElement markup="styled"> <paragraph leftIndent="5" spacingBefore="4"/> </textElement> <textFieldExpression><![CDATA[<style pdfFontName="TimesNewRoman" isPdfEmbedded="true">$F{name} </style>]]></textFieldExpression></textField> I can't believe that there isn't some way to accomplish this. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now