Jump to content

Recommended Posts

Posted

In my version of Jasper reports (from 2/28/06), the bold style is not appearing in pdf output. If I have stylized text (for example, "<b>This</b> should be <b>bold</b>"), the bold parts appear bold in the jasper output, but not in the pdf. The only way I can get bold in pdf is to force the pdf font for that element to be a bold font (pdfFontName="Helvetica-Bold" for example), but that bolds the entire string and does not allow me to control it via the style markup <b>.

Does Jasper support stylized bold markup in pdf output? Am I just missing something here?

  • Replies 16
  • Created
  • Last Reply

Top Posters In This Topic

Posted

Hi,

 

Yes, you are missing the font mappings that need to be passed to the exporter using the FONT_MAP exporter parameter.

You can see this being used inside our /demo/samples/styledtext sample provided with the project.

 

I hope this helps.

Teodor

  • 2 years later...
Posted

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);
  • 1 month later...
  • 10 months later...
Posted

 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?

Posted

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

Posted

I want to stay away from the arial font and embedding.

the question is how does iReport 3.7.1 work with just:

<font isBold="true" />

 

while when in application it doesn't? does ireport pass extra params/maps? use extra libraries?

Posted

@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
Posted

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>

Post Edited by hopesolutions at 04/01/2010 13:39
  • 4 months later...
Posted

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

  • 1 month later...
Posted

Hi,

Do i need to change the jrxml or the exporter?

I tried making a jar out of the components you suggested and got the jar in my classpath, yet isBold is not working for me.

  • 3 years later...
  • 1 year later...
  • 5 months later...
  • 3 years later...
Posted

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!

  • 7 months later...

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...