2

I have a problem with fonts in jasper report, this is my code:

<textField>
    <reportElement x="0" y="2" width="40" height="20" forecolor="#E36C0A"/>
    <textElement verticalAlignment="Bottom">
        <font size="12" pdfFontName="../../css/custom/fonts/amrgarab.TTF"/>
    </textElement>
    <textFieldExpression><![CDATA[$P{centre}.getShortName().get($P{locale})]]></textFieldExpression>
</textField>    

Ok, the problem is that it writes but not using the font amrgarab.TTF

I read a lot about this, and I don't want to "install" in the server, I add the font to my project, can I do that? If I can do that, why doesn't it work?

Alex K
  • 22,315
  • 19
  • 108
  • 236
Marta
  • 133
  • 1
  • 1
  • 4

2 Answers2

3

You can add the attribute isPDFEmbedded="true" to your font declaration. This should then embed the font into the PDF file (as long as the font you've referenced is available when the report is exported).

With the font embedded in the file, it will always be available to the reader, so there is no need to have the font installed on the machine. The only caveat is that it will make your PDF files bigger.

EDIT

In jasper report version 5,6 you should use Font Extension to correctly embed and render font in pdf () see

Checklist to render font in pdf using font extensions

Creating font extensions with iReport or JasperStudio Soft

Community
  • 1
  • 1
GenericJon
  • 8,746
  • 4
  • 39
  • 50
  • This method is deprecated, now you use Font Extensions... I suggest you update post with this info.. – Petter Friberg Dec 04 '15 at 20:17
  • @PetterFriberg I rarely use jasper reports these days, so I don't know anything about Font Extensions. Perhaps you could add another answer with the details? – GenericJon Dec 16 '15 at 14:15
  • 1
    I have edit your post, to include notes on Font Extensions, with link to accepted solutions on SO, I hope it is useful. (If you don't like feel free to roll back) – Petter Friberg Dec 16 '15 at 17:19
2

I know this is a bit late answere XD, but now you have an oficial simple guide on how you could do this steps by steps.

GUIDE

It tells you how to used it on a simple jasper report file, and then how to export and import it to be used on all reports.

UHDante
  • 577
  • 9
  • 21