Font used in Jaspersoft isn't available in JVM - java

I'm getting an net.sf.jasperreports.engine.util.JRFontNotFoundException. I've already added the font in Jaspersoft Studio like how it was described here: When export a report to PDF change the font .
I've also exported the font extension and placed the jar where my classpath can see it like how it was described here: How can I display "$£Ω€απ⅔" in Jasperserver PDF using iReport? .
I'm still getting the error. Does anybody know any other solution that might help? Thanks in advance.

I ran into similar problem. The cause of my problem was that the font I was trying to use was installed on my computer (Windows) but was not installed on our deployment environment (Linux). So the problem occurred on Linux. So we needed simply to install required font on that system. (The problem occurred for PDF files only). So, check if you actually have the font in question on your system (try to find it in editor (such as MS Word - for windows). If you don't have the phont, install it. Google "How to add tryetype font on [your system name: Windows, Linux or whatever you are using]"

I solved this problem by exporting it as .zip instead of .jar, extracting the contents of the .zip and placing them under classpath.
More details on this in this blog (Solution 3): http://poor-developer.blogspot.com/2017/02/jasper-reports-using-unavailable-fonts.html

Related

Jasper report not picking up fonts when running on linux [duplicate]

I'm trying to generate report with DynamicJasper, but I'm getting the following error:
net.sf.jasperreports.engine.util.JRFontNotFoundException:
Font 'Arial' is not available to the JVM.
msttcorefonts is installed, but I guess the JVM is not using any fonts from it.
I'm using Ubuntu 10.04.
How can I fix this?
I tried installing mscorefonts, but the package was installed and up-to-date.
sudo apt-get update
sudo apt-get install ttf-mscorefonts-installer
I tried searching for the font in the filesystem, with:
ls /usr/share/fonts/truetype/msttcorefonts/
This folder just had the README, with the correct instructions on how to install.
cat /usr/share/fonts/truetype/msttcorefonts/README
You need an internet connection for this:
sudo apt-get install --reinstall ttf-mscorefonts-installer
I re-installed ttf-mscorefonts-installer (as shown above, making sure to accept the EULA!) and the problem was solved.
JasperReports raises a JRFontNotFoundException in the case where the font used inside a report template is not available to the JVM as either as a system font or a font coming from a JR font extension. This ensure that all problems caused by font metrics mismatches are avoided and we have an early warning about the inconsistency.
Jasper reports is trying to help you in your report development, stating that it can not export your report correctly since it can not find the font defined in TextField or StaticText
<font fontName="Arial"/>
Yes you can disable this by setting net.sf.jasperreports.awt.ignore.missing.font to true but you will have export inconsistencies.
Yes you can install the font as JVM system font (but you need to do it on every PC used that may generate report and you can still have encoding problems).
The correct way!
Use Font Extensions!, if you like to create your own (see link below), jasper reports also distributes a default font-extension jar (jasperreports-fonts-x.x.x.jar), that supports fontName DejaVu Sans, DejaVu Serif and DejaVu Sans Mono
<font fontName="DejaVu Sans"/>
From the JasperReport Ultimate Guide:
We strongly encourage people to use only fonts derived from font
extensions, because this is the only way to make sure that the fonts
will be available to the application when the reports are executed at
runtime. Using system fonts always brings the risk for the reports not
to work properly when deployed on a new machine that might not have
those fonts installed
Links on StackOverflow on how to render fonts correctly in pdf
Checklist on how to render font correctly in pdf
Generate font-extensions with JasperSoft Studio
Generate font-extensions with iReport
I use IReport to install font:
tools -> options -> fonts -> click install font
Then select the font and click
-> export as extension and type name myfont.jar
add this jar and also spring.jar* to your build path.
*copy spring.jar from Jaspersoft\iReport-3.7.0\ireport\modules\ext
sudo apt-get install msttcorefonts works (on our Ubuntu development environment), but is not a very good solution.
Instead, we bundled the fonts with our application based on this tip. Their JAR file bundles the following fonts,
Arial
Times New Roman
Courier New
Comic Sans MS
Georgia
Verdana
Monospaced
Direct Link to download jar:
Maven ver 1.0. DynamicFonts
There are three method to avoid such a problem.
Method 1 : by setting ignore missing font property.
JRProperties.setProperty("net.sf.jasperreports.awt.ignore.missing.font", "true");
or you can set this property by entering following line into .jrxml file.
<property name="net.sf.jasperreports.awt.ignore.missing.font" value="true"/>
Method 2 : by setting default font property.
JRProperties.setProperty("net.sf.jasperreports.default.font.name", "Sans Serif");
or you can set this property by entering following line into .jrxml file.
<property name="net.sf.jasperreports.default.font.name" value="Sans Serif"/>
Method 3 : by adding missing font property.
Firstly install missing fonts in IReport by selecting " Tools >> Options >> Fonts >> Install Font " then select the all font and Export this By clicking on "Export as Extension" with .jar Extension.
You can use this jar for Jasperreports-font.X.X.X.jar which will be present in your project library or classpath.
For CentOS:
wget msttcorefonts
Then:
tar -zxvf msttcorefonts.tar.gz
cp msttcorefonts/*.ttf /usr/share/fonts/TTF/
fc-cache -fv
After all, restart JVM.
I solved this by choosing 'SansSerif' or 'Serif' only and not 'Arial' or 'Times New Roman'.
If you are using maven in your project, you can just add the jasper-fonts dependency to pom.xml:
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports-fonts</artifactId>
<version>6.8.1</version>
</dependency>
Installing the missing font on the system may be a working solution but not for me, I didn't want to have to install the missing fonts after each deployment in a new server, instead I opted for embedding the font with the application.
Regards.
Try adding the line
net.sf.jasperreports.awt.ignore.missing.font=true
to your jasperreports.properties file.
Jasper stops finding one font
For Debian
add
non-free contrib
to deb and deb-src in /etc/apt/sources.list ie:
deb http://ftp.debian.org/debian/ squeeze main non-free contrib
deb-src http://ftp.debian.org/debian/ squeeze main non-free contrib
Then
apt-get update
apt-get install msttcorefonts
Of course you'll need to restart jasperserver. ie:
/opt/jasperreports-server-cp-4.5.0/ctlscript.sh restart
Change for your version / path.
I faced the issue with my web application based on Spring 3 and deployed on Weblogic 10.3 on Oracle Linux 6. The solution mentioned at the link did not work for me.
I had to take the following steps -
1. Copy the Arial*.ttf font files to JROCKIT_JAVA_HOME/jre/lib/fonts directory
2. Make entries of the fonts in fontconfig.properties.src
3. Restart the cluster from Weblogic console
filename.Arial=Arial.ttf
filename.Arial_Bold=Arial_Bold.ttf
filename.Arial_Italic=Arial_Italic.ttf
filename.Arial_Bold_Italic=Arial_Bold_Italic.ttf
You can do it by installing fonts, that means everywhere you want to run that particular application. Simplest way is just add this bl line to your jrxml file:
<property name="net.sf.jasperreports.awt.ignore.missing.font" value="true"/>
can make your custom fonts via iReport and converting like jars files
Create jasper report in multiple languages(Unicode)
1)Install font in ireport desginer
2)create extension of font(we will use it in applications classpath)
3)install font on os(optional)
4)paste all .ttf of font in jre->lib->fonts directory (otherwise web application will throw error font is not available to JVM)
You can use this library which packages the Liberation-fonts as JasperReport font extension, and registers them as Arial, Times New Roman and Courier:
https://mvnrepository.com/artifact/com.mpobjects.jasperreports.font/jasperreports-fonts-liberation
Actually I fixed this issue in a very simple way
go to your home path, like /root
create a folder named .fonts
copy your all your font files to .fonts, you can copy the font from C:\windows\fonts if you use windows.
sudo apt-get install fontconfig
fc-cache –fv to rebuid fonts caches.
Solution in 2 steps (if you are using centOS)
Download the Microsoft core fonts rpm package.
[root#WEBSVR~/]# wget http://www.itzgeek.com/msttcore-fonts-2.0-3.noarch.rpm
Install rpm package.
[root#WEBSVR~/]# rpm -Uvh msttcore-fonts-2.0-3.noarch.rpm
Add the below in your .jrxml file:
<property name="net.sf.jasperreports.awt.ignore.missing.font" value="true"/>
Copy your Fonts on the following directory
JDK_HOME\jre\lib\fonts
Hey Having trouble viewing documents produced on Windows?
You can try a fine solution easy:
yum install curl cabextract xorg-x11-font-utils fontconfig
rpm -i
https://downloads.sourceforge.net/project/mscorefonts2/rpms/msttcore-fonts-installer-2.6-1.noarch.rpm
After this I need reboot my system CentOS6.
Source: http://mscorefonts2.sourceforge.net/

VLCJ: Packaged Jar cant load libvlc library when double-clicked but runs perfectly through console

I have a problem with vlc.I am using Eclipse and have made a small application to play video files using vlcj framework.Inside Eclipse everything works fine but when I make jar executable file through Eclipse and double-clicking it (on Windows 64: Tested only on this platform) nothing happens .Then I'm trying using "cd myjarfilepath" and then "java -jar myjarname.jar" and everything works fine.Why this is happening and how to solve it?
Thanks in advance to stackoverflow's community .
Edit:
In Path Location: C:\Users\user\Documents\31\Latest_Win64\Needed I have the following files:
plugins(directory)
axvlc.dll
axvlc.dll.manifest
libvlc.dll
libvlc.dll.manifest
libvlccore.dll
npvlc.dll
npvlc.dll.manifest
vlc.exe.manifest
In my classpath i have included the following files:
jna-3.5.1.jar
platform-3.5.1.jar
vlcj-2.2.0.jar
vlcj-2.2.0-javadoc.jar
vlcj-2.2.0-sources.jar
This sounds like an issue loading the needed VLCj files. Not only are dlls required but the plugin directory is also required. As the execution location moves around from inside eclipse to back in the file system, the path to these files may be getting set incorrectly.
It sounds like you have it working within eclipse. This would indicate to me that what you have should work. Firstly, I would recommend acquiring the VLC dlls, etc., by providing this as a VM argument such as shown below, rather that setting it in code. Remember to comment out any loading you are doing in your code so that you are relying on the command line argument.
-Djna.library.path={Application Location}/lib
example: -Djna.library.path=C:/myapp/lib
Directory Contents:
lib
-- libblc.dll
-- libvlc5.dll
-- {etc}
/plugins
/3dnow
/access
{etc}
If you are still having issues, add the following argument to put VLCj into debug mode. This can be very helpful to determine where things are failing.
-Dvlcj.log=DEBUG
Hope that helps.

Blank(white) textfields in iReport 4.6.0

I began using iReport for creating JasperReports since version 4.5.1 and then I started using 4.6.0 and created a couple of reports with it. The problem is that whenever I open the "old reports" (generated in 4.5.1) the textfields' fonts appear white coloured (it becomes "invisible" to me). When I double-click it, it shows the text, but it's terrible for edition because I can't see how the text is being displayed on the page.
It works fine with documents created by 4.6.0 and opened by 4.6.0, but not with documents created by previous versions. I guess it has to do with its xml (an attribute maybe).
Things I tried:
(1) Select another colour [green] for the font. (2) Open the .jasper compiled file and generate a new .jrxml.
Thanks in advance :D
Nevermind, I found out what was causing the "bug". It happens that the first report I created in iReport 4.5.1 was saved on Windows with Arial font (which doesn't exist in Ubuntu/Linux). So I deleted the "fontName" tags on the JRXML file.
Some fonts are not available on linux and if your report template use them, you will have the described problem. If you want to still use the Arial or some other non-linux fonts, you can try to install this package and retry:
sudo apt-get install msttcorefonts

Error in deleteing Java Temp file using Ghost4j sample code

Hi I tried to run http://ghost4j.sourceforge.net/highlevelapisamples.html PDF to PS sample code and it produce this error for me "ERROR: Temporary file /var/folders/8a/8a7E-LirFfeAJh+EC93W4U+++TY/-Tmp-/ghost4j/java.io.FileOutputStream#252f09991304994155878469 cannot be deleted" has anyone encounter this before and currently I am running on mac. Thanks!
Hi I had the same problem, but on windows 7..but I think is for the same reason.
problem was that ghost4j couldn't find the ghostscript libraries so it was failing here
result = GhostscriptLibrary.instance.gsapi_set_stdio(getNativeInstanceByRef().getValue(), stdinCallback, stdoutCallback, stderrCallback);
when trying to initialise the ghostscript libraries.
So I moved the library files to the directory in which I imported the sources.
As I'm running a 64 bit system I also had to change their name in "GhostscriptLibrary.java".
I found the library files installing ghostscript from http://downloads.ghostscript.com/public/
I'm quite sure is not the best way of solving the problem, but it worked for me.
hope it will help you.

where is the NetBeans config file (netbeans.conf) located?

my NetBeans has ugly fonts in interface. I'm going to make antialiasing for it. In internet I saw that there is should be
-J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=on
in netbeans_default_options. This file should be located in /etc/netbeans.conf. But there isn't this file. I have NetBeans 6.8. Help, please.
UPD:
[ockonal#wincode ~]$ cd ~/.netbeans/6.8/
[ockonal#wincode 6.8]$ ls
ant build.properties docs lib modules sources
update_tracking bin config
jsstubs lock native update var
UPD2
With utilite find I did:
find / -name 'netbeans.conf'
This gave me:
/usr/share/netbeans/etc/netbeans.conf
In my NetBeans 6.7, this file is located at
{netbeans-installation-dir}/etc/netbeans.conf
I guess if you are using Windows, and the default folders, you should be able to find somewhere here:
C:\Program Files\NetBeans 6.8\etc\netbeans.conf
On a linux box, you should be able to find the file somewhere here
On Linux the installer lets the user choose where you want to install NetBeans. You may find it under /home/yourname/netbeans/etc/netbeans.conf or /opt/netbeans/etc/netbeans.conf. [ from http://wiki.netbeans.org/FaqNetbeansConf ]
On an ubuntu platform you can use the following command
locate netbeans.conf
to find where the netbeans files are located. It's the best way that provides with a precise location of your netbeans.conf file.
Hope this will help someone in need.
On Mac OS X:
/Applications/NetBeans/NetBeans XXX.app/Contents/Resources/NetBeans/etc/netbeans.conf
(Where XXX is The installed version of NetBeans)
Example for NetBeans 8.0:
/Applications/NetBeans/NetBeans 8.0.app/Contents/Resources/NetBeans/etc/netbeans.conf
Current as of this date for Windows, go to %APPDATA%\NetBeans, then the version (I have 8.2 and dev). In there you'll find a config folder with tons of stuff under it. I came to this Q&A looking for info on fonts and colors. That info is now found under config\Editors. Some base info for your themes are in there under FontsColors. Styling and color details are under folder text, and then in subfolders similar to the above.
As an example, I went to tools>options>Fonts&Colors. I duplicated the Darcula profile into (my initials) TGDark to make changes. Then to Syntax, HTML, and "Javascript Embedded in HTML", I set the background color to #3F2B2B. Now, in the file system I found this setting under:
C:\Users\tony\AppData\Roaming\NetBeans\dev\config\Editors\text\html\FontsColors\TGDark\org-netbeans-modules-editor-settings-CustomFontsColors-tokenColorings.xml
And in that file, note the bgcolor:
<fontcolor bgColor="ff3f2b2b" default="default" name="javascript-embedded"/>
What an adventure...
In Arch/Manjaro it's in /usr/etc/netbeans.conf (locate netbeans.conf is our friend)
in linux:
usr/local/netbeans.{version}/etc/netbeans.conf
In macOS for the latest release Apache NetBeans 14 it's located here:
"/Applications/NetBeans/Apache NetBeans 14.app/Contents/Resources/NetBeans/netbeans/etc/netbeans.conf"

Categories