I have a problem that have been already asked, but there are some specific differences in my case.
I'm supporting a web application (EJB 2, PostgreSQL 9.2.4, running on a JBoss 4.2.3) that have an issue.
Sometimes, when we try to generate a specific report, we get this error:
javax.servlet.ServletException: net.sf.jasperreports.engine.JRRuntimeException: Could not load the following font :
pdfFontName : DejaVu Sans
pdfEncoding : Cp1252
isPdfEmbedded : false
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
stirq.scan.util.NoCacheFilter.doFilter(NoCacheFilter.java:38)
jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:118)
stirq.scan.util.TimeoutFilter.doFilter(TimeoutFilter.java:57)
stirq.scan.util.SecurityFilter.doFilter(SecurityFilter.java:82)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
I searched in many sites.
http://community.jaspersoft.com/questions/525505/could-not-load-following-font
Could not load the following font issue in iReport
JasperReports - font extensions does not work - can't find font while exporting to PDF
(And others)
As suggested in many answers, I am using font extension jar but still got the issue.
There are two fields of a table in the application's database that can contains html code.
I found that the bug occurs when there is a "font" tag in one of those two fields or the two.
Even if the specified font in this "font" tag is Arial the message I got is still concerning the font DejaVu Sans.
Every textfield of all my jrxml files are in font DejaVu Sans.
When I tested the preview mode of my report in IReport 4.1.1 every thing was fine.
I deleted every "font" tags of the two database fields containing HTML code for an occurrence that got the issue and it worked.
But the application is in production.
As you can see I can't delete every "font" tags in the database.
Any help would be appreciated.
Thanks.
In iReport if you set up a repository for your JasperServer you will be able to get the effective production version of a report xml into iReport. Then you can edit your file and replace by the edited version production one.
try setting up these system properties:
import net.sf.jasperreports.engine.util.JRProperties;
JRProperties.setProperty("net.sf.jasperreports.default.pdf.font.name", "Helvetica")
JRProperties.setProperty("net.sf.jasperreports.default.pdf.encoding", "UTF-8")
JRProperties.setProperty("net.sf.jasperreports.default.pdf.embedded", "false")
see here for more: http://www.77dev.com/2014/07/could-not-load-following-font-solved.html
Copy the fonts files (*.ttf) into the folder:
/path/to/app/WEB-INF/classes/
You app will get the fonts from here :)
Related
I'm using Thymeleaf template engine, and want to get the charset attribute value for the meta tag on the head block from my project properties, i.e :
<meta th:charset="${#environment.getProperty('html.charset')}">
But when I want to save my html file I get this pop-up error :
Save could not be completed. Try File > Save As... if the problem persists.
Reason:
Character encoding "${#environment.getProperty('html.charset')}" is not a legal character encoding.
I even tried to save the file from outside of eclipse, but when back on eclipse and want to open the file, I couldn't access it and got this error :
Unsupported Character Encoding
Character encoding "${#environment.getProperty('html.charset')}" is not supported by this platform.
Set Encoding...
I tried to suspend all validators on eclipse Preferences but this doesn't resolve the problem.
Any ideas for help ? Thanks in advance.
I'm on Mac OS and using Eclipse IDE for Enterprise Java and Web Developers, Version: 2021-09 (4.21.0).
The charset value is being used, regardless of the prefix, to read and write the file correctly. That there is a prefix on the attribute in a non-prefixed meta tag is a clue that it should be ignored by the normal encoding detection. Please open a bug report for this.
For a workaround, force the use of the encoding you want using the file's Properties dialog's Resource page (get there by right-clicking on the file).
I'm developing an aplication that generates a PDF using Jasper. To do this I have a custom font that I generate in Jasper but the problem is I can't put this working. Every time that I try to generate the document gives me the following error:
Caused by: net.sf.jasperreports.engine.util.JRFontNotFoundException: Font "reportFonts" is not available to the JVM. See the Javadoc for more details.
I'm on IntelliJ and I already setup the font jar in the project path like the this
And the library looks like this
What am I missing here?
Thanks
I created a jasper report and now I need to export that report to pdf format. This is my code for that.
// compiles jrxml
JasperCompileManager.compileReportToFile(reportName + ".jrxml");
// fills compiled report with parameters and a connection
JasperPrint print = JasperFillManager.fillReport(reportName + ".jasper", parameters, connection);
// to view the report
//JasperViewer.viewReport(print, false);
// export repor to pdf
JasperExportManager.exportReportToPdfFile(print, "fromXml.pdf");
When I view the report using JasperViewer, it works fine. But When I exporting the report into pdf format, it gives me the following exception.
Exception in thread "main" java.lang.NoClassDefFoundError: com/itextpdf/text/DocumentException
But I have put the iText jar into my libraries.
But one thing, I had another version of iText jar before. It gave me the same exception. I thought that there may be some issues with the version of it.(I followed a tutorial, so I added the same jar as they had used in the tutorial replacing the new jar I had used).
but still the problem remains. I thought this may be the issue now(the accepted answer of the question). But I do not know how to fix it. I removed the entire library and added it again with iText jar which had been used by the tutorial. But I had no luck.
Could you please help me to overcome this issue.
Thank you!
You need to upgrade your iText-2.1.7.jar file to latest version as earlier the package that was used by jar is com.lowagie...
See the change list here which says it has changed the package name.
Is there a system property or other parameter that can be passed to PDFBox when attempting to convert from a PDF document into an Image? I am utilizing the provided PDF2Image class like so:
String[] args = new String[]{"-imageType", "jpg", "myfile.pdf"};
org.apache.pdfbox.PDFToImage.main(args);
It works great on Windows and fails with this warning on Ubuntu:
[org.apache.pdfbox.util.PDFStreamEngine] java.lang.NullPointerException java.lang.NullPointerException at org.apache.pdfbox.pdmodel.font.PDType1Font.getawtFont(PDType1Font.java:261)
I assume from my research that this is a problem with a "missing" font, but I've found very little help so far using google and the projects website.
I've tried both versions 1.7.1 and 1.8.2 of PDFBox.
Similar question here: setting ttf for PDF to Image on PDFbox
iReport Version : 3.7.1
I approached this problem in two ways.
My first method
I am creating a pdf page in iReport and I have one of the fields (from database) set to a font Gujarati-Salarl (A font for a regional language of India).
This font is available in the font list of iReport.
When I hit preview I get the desired output , with the field in the required font style.
Everything till here is fine.
But the pdf file generated still contains the same original font in English characters.
The result is same whether i call the report from the application or from a JAVA file.
After a bit of study I found this , a second method
JRProperties.setProperty("net.sf.jasperreports.default.pdf.font.name", "C:\\Gujrati-Saral-1.ttf");
This sets the font of the pdf to the ttf font provided but now the entire pdf comes in the Guarati-saral font which is not what I am looking for..
Is there a way to specifically apply this font only to that one particular field?
or
when going by the second method is there a way to not applying the font Guarati-saral to all other fields except the required one ?
You should use the Font Extensions mechanism.
After creating the font and exporting it as a jar file you should add generated jar file to the application classpath.
a) Creating new font in iReport (via Options -> Fonts -> "Install Font" Button)
b) Exporting the new font (or the existing one) as jar file in iReport (via Options -> Fonts -> "Export as extension" Button)
a) Creating new font in JasperReports Studio (via Window -> Preferences -> JasperStudio -> Fonts -> "Add" Button)
b) Configure your fonts
c) Create JAR with your fonts in it
You can find more information about using Font Extensions here.
if you have problems displaying UTF-8 characters in the pdf,
from version 4.8.0 of the IReport, no need to do nothing!
Just change the font of the cells in the table from sanserif to Dejavu sans.
thats it.
For those, who need Russian language in Jasper Reports (at least in opennms of old versions), following combination does the trick without using the Font Extension:
Font Name: SanSerif
PDF Font: Courier
PDF Encoding: CP1251
PDF Embedded: Yes (not sure, may be it works even without)
Alexey Bakhmutov
Select the field and go to filed properties and change the
select DejaVu Sans as Font Name
select Pdf Encoding to CP1256 (Arabic)
select pdf font name to Courier
with these changes in I got arabic data showing in PDF.