Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Change Font for Report Print-friendly Version
Dudu
Hi all,
I have an application that needs to generate the same reports in HTML and PDF. In my Birt report design I've used Tahoma font family to create the reports and they look great in HTML version, but I want the use a different font family when rendering the report in PDF A serifed font like Times New Roman, for example.
Is there a way to do this programatically? Changing something in PDFRenderOption object for example.
I've found a solution changing fontsConfig_PDF.xml file, forcing Birt to map Tahoma into Times-Roman font family but I do not think this is the most elegante solution.
My solution:
<font-aliases>
...
<mapping name="Tahoma" font-family="Times-Roman" />
</font-aliases>
Thanks.
Carlos Lopes
Find more posts tagged with
Comments
mwilliams
Hi Carlos,
You may be able to do this with style sheets. Changing which one you use depending upon output type. I have not tried this yet, but I'll check it out and let you know. I'm not sure if you can change style sheets after you figure out what the output is. I'll let you know. Or if you try it before I get back to you, let me know.
Dudu
Hi,
thanks for the style sheets idea. I've tried changing the report rptlibray files (that is where the report styles are stored) but there were session on the report XML file that could were the library were used and could not be replaced just changing files.
So I've came up with a solution were I've added a script for On Render event for each element of the report. The code was the following:
if(reportContext.getOutputFormat() == "pdf"){
if(this.getStyle() != null) {
this.getStyle().fontFamily = "Times-Roman";
}
}
The problem with this solution is that I need to change every element in the report :-( It would be nice if there is a method that I could retrieve all report elements of the report and create a method using the code above to set all of them in a single loop, or even a recursion (if the elements are in a tree structure).