Fix itext 5.0.1 generate PDF, add Itextasian.jar exception Font ' stsong-light ' with ' unigb-ucs2-h ' are not recognized.

Source: Internet
Author: User

Itext the latest version of 5.0.1, the official binary version of the Asian font is still not directly integrated solution, loading Itextasian.jar to Classpath has not been working, prompted the following error:
Font ' stsong-light ' with ' unigb-ucs2-h ' isn't recognized
The whole day did not get to the path, had to go to view the source code, find the Cjkfont class, from which to see
InputStream is = Getresourcestream (Resource_path + "cjkfonts.properties");
Cjkfonts.load (IS);
Is.close ();
is = Getresourcestream (Resource_path + "cjkencodings.properties");
Cjkencodings.load (IS);
Is.close ();
His font and encoding files are all from string Resource_path = "com/itextpdf/text/pdf/fonts/"; Here loaded, and the old Itextasian.jar package name is com.lowagie.text.pdf.fonts, should be the package name renamed, and did not update Itextasian.jar, changed the Itextasian.jar package path, Re-run the program, OK, done.

Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Here's how to change the Itextasian.jar package name
1) Use the WinRAR decompression program to extract the original Itextasian.jar, the directory structure is as follows
Itextasian
--com
--lowagie
--text
--pdf
--fonts
--... (Font properties file)
2) Change the package name Lowagie under pressurized COM directory to Itextpdf
3) go to the Itextasian directory on the command line and repackage to the Itextasian.jar file
The command is as follows:
Jar CVF Itextasian.jar com/itextpdf/text/pdf/fonts/*
After execution, add the new Itextasian.jar to the classpath path
Note: Google has a bit, itext from 5.0.0, but Itextasian.jar's package naming has not changed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.