Related ja bag: Itext-5.0.6.jar,itextasian-1.5.2.jar.
Note: You must modify the package path in the Itextasian-1.5.2.jar with WinRAR or haozip to change the package path to com.itextpdf.text.pdf.fonts. Otherwise, the PDF-times error is generated.
Example code:
Package com.xy6;
Import Java.io.File;
Import Java.io.FileOutputStream;
Import Java.io.OutputStream;
Import Java.util.Date;
Import Com.itextpdf.text.BaseColor;
Import com.itextpdf.text.Document;
Import Com.itextpdf.text.Font;
Import Com.itextpdf.text.Paragraph;
Import Com.itextpdf.text.pdf.BaseFont;
Import Com.itextpdf.text.pdf.PdfWriter; public class Demo1 {/** * @param args */public static void main (string[] args) {try{outputstream file = NE
W FileOutputStream (New File ("E:/demo1.pdf"));
Document doc = new document ();
Pdfwriter.getinstance (doc, file);
Doc.open ();
Basefont Bfchinese = Basefont.createfont ("Stsongstd-light", "Unigb-ucs2-h", false);
Font Fontchinese = new Font (bfchinese,12,font.normal,basecolor.black);
Paragraph PF = new Paragraph ("abc");
Pf.add (New Paragraph ("Shenzhen", Fontchinese));
Pf.add (New Paragraph () (New Date (). toString ()));
Doc.add (PF);
Doc.close ();
File.close ();
SYSTEM.OUT.PRINTLN ("---done");
} catch (Exception ex) { Ex.printstacktrace (); }
}
}