Cetnos 7 使用jasperreport 字型問題解決方式

Centos預設並沒有中文字型檔,所以當jasperreport要產生報表時,全出現字型檔在JVM裡不可用的狀況。

Font ‘Times New Roman’ is not available to the JVM. See the Javadoc for more details.

這時候只需要加入字型檔就可以了,之後記得要重啟java servlet containter( ex.tomcat)

Microsoft core TrueType fonts及dejavu fonts

debian

sudo apt-get install ttf-dejavu-core ttf-dejavu-extra -y
wget http://ftp.de.debian.org/debian/pool/contrib/m/msttcorefonts/ttf-mscorefonts-installer_3.6_all.deb
sudo dpkg -i ttf-mscorefonts-installer_3.6_all.deb

ubuntu

sudo apt-get install ttf-dejavu-core ttf-dejavu-extra -y
sudo apt-get install ttf-mscorefonts-installer

centos

sudo yum install  dejavu-fonts-common.noarch dejavu-sans-fonts.noarch dejavu-sans-mono-fonts.noarch dejavu-serif-fonts.noarch

mscorefonts可參考

https://centos.pkgs.org/7/nux-dextop-x86_64/msttcore-fonts-installer-2.6-1.noarch.rpm.html

  1. Download the latest nux-dextop-release rpm from
    http://li.nux.ro/download/nux/dextop/el7/x86_64/
  2. Install nux-dextop-release rpm:
    # rpm -Uvh nux-dextop-release*rpm
  3. Install msttcore-fonts-installer rpm package:
    # yum install msttcore-fonts-installer

最後記得重啟java servlet container就好了

發表迴響