Does Jasper support stylized bold markup in pdf output? Am I just missing something here?
14 Answers:
Hi Teodor,
Does JasperReport 1.1.0 support this feature?
I have added FONT_MAP parameter to PDF exporter - did not help.
I think this is because PdfFont class does not have 2 new extra attributes:
- boolean isPdfSimulatedBold
- boolean isPdfSimulatedItalic
Is there any other way in this version to tell to PDF exporter about stylized text markup ?
Thank you
Code: |
JRPdfExporter exporter = new JRPdfExporter(); FontKey keyArial = new FontKey("Arial", false, false); PdfFont fontArial = new PdfFont("Helvetica","Cp1252",false); FontKey keyArialBold = new FontKey("Arial", true, false); PdfFont fontArialBold = new PdfFont("Helvetica-Bold","Cp1252",false); Map fontMap = new HashMap(); fontMap.put(keyArial,fontArial); fontMap.put(keyArialBold,fontArialBold); exporter.setParameter(JRExporterParameter.FONT_MAP,fontMap); </td></tr></tbody></table> |
Ok, this thread is old, but i still have the issue:
I upgraded from jasper-reports 2.0.5 to 3.7.1, and started updating the jrxmls. before i uses to use pdfFontName="Helvetica-Bold" to get the bold effect, but now i am using only isBold="True".
in iReport the preview is ok, but printing from the web application i get no bold at all.
what should i do to enable the isBold on the default Helvetica font? FONT_MAP is old as many writes in this forum.... is there a ready font-extgension for helvetica fonts?
Pdf Embedded mode was turned on?
<font fontName="Arial" pdfFontName="arialbd.ttf" isPdfEmbedded="true"/>
In my sample, html report file will be in Arial font and normal style. But in pdf file, it displayed in bold style.
Remember copy arialbd.tff font to your application class path.
Äức, Trần Minh ductm@fpt.com.vn
@hopesolutions:
Nothing extra library need here.
In font tag, fontName, isBold, isItalic or isUnderline property are not useful for pdf report exporter.
In pdf report , the text style depend on the font filename.
Example: If you want the text in pdf report file in Arial and :
- Bold: pdfFontName="arialbd.ttf"
- Italic: pdfFontName="ariali.ttf"
...
make sure isPdfEmbedded="true" and embeded fonts were on your classpath application
<font pdfFontName="arialbd.ttf" isPdfEmbedded="true"/>
Äức, Trần Minh ductm@fpt.com.vn
Post Edited by minhduc at 04/01/2010 11:17
I might have fixed the issue by making a font extension to map standard SansSerif font to Arial, with nothing to change in current reports, just put the jar in the application folder and printing shows bold with only isBold....
Code: |
<bean id="fontSansSerifFamily" class="net.sf.jasperreports.engine.fonts.SimpleFontFamily"> <property name="name" value="SansSerif"/> <property name="normal" value="fonts/arial.ttf"/> <property name="bold" value="fonts/arialbd.ttf"/> <property name="italic" value="fonts/ariali.ttf"/> <property name="boldItalic" value="fonts/arialbi.ttf"/> <property name="pdfEmbedded" value="false"/> </bean></td></tr></tbody></table><br><br>Post Edited by hopesolutions at 04/01/2010 13:39 |
The solution provided by "hopesolutions" works fine!
I added to the java classpath ( /WEB-INF/classes ):
1) jasperreports_extension.properties:
net.sf.jasperreports.extension.registry.factory.fonts=net.sf.jasperreports.extensions.SpringExtensionsRegistryFactory
net.sf.jasperreports.extension.fonts.spring.beans.resource=fonts.xml
2) fonts.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="fontSansSerifFamily" class="net.sf.jasperreports.engine.fonts.SimpleFontFamily">
<property name="name" value="SansSerif"/>
<property name="normal" value="fonts/arial.ttf"/>
<property name="bold" value="fonts/arialbd.ttf"/>
<property name="italic" value="fonts/ariali.ttf"/>
<property name="boldItalic" value="fonts/arialbi.ttf"/>
<property name="pdfEmbedded" value="false"/>
</bean>
</beans>
3) "fonts" folder containing these fonts:
arial.ttf
arialbd.ttf
arialbi.ttf
ariali.ttf
Hope this helps!
Marco
I recently came across the same problem and simply dragging the jasperreports-fonts-6.7.0.jar file into my project fixed this. In an attempt to minimise the number of jar files I'd not included this jar file even though it was part of what I'd downloaded from the site!
I am using tibco software for designing the jasper report, in my case i am able to generate the bold text in PDF for solution check on this blog
https://real-world-reality.blogspot.com/2020/02/how-to-get-bold-text-whi...
Thank you so much! This really helped me.
Thank you!