Unwanted font Helvetica in PDF from Jasper
When I 开发者_高级运维create a PDF from a Jasper Report, the resulting PDF declare to use "Helvetica" font, even if it doesn't contain text. Unfortunately I cannot embed "Helvetica" font, because it is not among the Windows fonts. Based on the PDF/A rules, I need to embed all the fonts in the PDF file.
How can I create from Jasper a PDF that doesn't declare to use Helvetica?
Thank you in advance.
Fabio
Here's an explanation by Teodor Danciu, the main architect of the JasperReports Library:
https://community.jaspersoft.com/jasperreports-library/issues/5368
Apparently, to avoid using Helvetica, you can create a default style that uses one of your fonts.
You could try out a few things, have you look into the reportFont element?
<!ELEMENT reportFont EMPTY>
<!ATTLIST reportFont
name CDATA #REQUIRED
isDefault (true | false) "false"
fontName CDATA #IMPLIED
size NMTOKEN #IMPLIED
isBold (true | false) #IMPLIED
isItalic (true | false) #IMPLIED
isUnderline (true | false) #IMPLIED
isStrikeThrough (true | false) #IMPLIED
pdfFontName CDATA #IMPLIED
pdfEncoding CDATA #IMPLIED
isPdfEmbedded (true | false) #IMPLIED
>
However, note that report fonts are now deprecated, so you might wanna check out the style element:
<!ELEMENT style (conditionalStyle*)>
<!ATTLIST style
name CDATA #IMPLIED
isDefault (true | false) "false"
...
forecolor CDATA #IMPLIED
isStyledText (true | false) #IMPLIED
fontName CDATA #IMPLIED
fontSize NMTOKEN #IMPLIED
isBold (true | false) #IMPLIED
isItalic (true | false) #IMPLIED
isUnderline (true | false) #IMPLIED
isStrikeThrough (true | false) #IMPLIED
pdfFontName CDATA #IMPLIED
pdfEncoding CDATA #IMPLIED
isPdfEmbedded (true | false) #IMPLIED
pattern CDATA #IMPLIED
isBlankWhenNull (true | false) #IMPLIED
>
pdfFontName should be the name of the font you are planning to use. This could either be a predefined PDF font or the name of a TTF file present in the classpath. In case you are using a TTF then note that isPdfEmbedded specifies whether an external TrueType font (TTF) file should be included in the PDF file or not
Regards!
精彩评论