Jump to content
We've recently updated our Privacy Statement, available here ×

Style field and parameter strings with pdf embedded font


RTThomas

Recommended Posts

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

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...