1。iTextAsian.jar包有没有加入。
2。源代码
import java.awt.Color;
import java.io.FileOutputStream;
import java.io.IOException;import com.lowagie.text.*;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfWriter;public class Chap0909 {
    
    public static void main(String[] args) {
        
        System.out.println("Chapter 9 example 9: CJK Fonts");
        
        // step 1: creation of a document-object
        Document document = new Document();
        Document.compress = false;
        try {
            
            // step 2:
            // we create a writer that listens to the document
            // and directs a PDF-stream to a file
            PdfWriter.getInstance(document, new FileOutputStream("Chap0909.pdf"));
            
            // step 3: we open the document
            document.open();
            String chinese = "我们是害虫";
            
            // step 4: we add content to the document
            BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
            Font FontChinese = new Font(bfChinese, 12, Font.NORMAL);
            Paragraph chunk = new Paragraph(chinese, FontChinese);
            document.add(chunk);
        }
        catch(DocumentException de) {
            System.err.println(de.getMessage());
        }
        catch(IOException ioe) {
            System.err.println(ioe.getMessage());
        }
        
        // step 5: we close the document
        document.close();
    }
}3。编译javac -encoding GBK -classpath d:\iText.jar;d:\iTextAsian.jar Chap0909.java
(假设相应的包重命名为iText.jar和iTextAsian.jar且在D盘下)4。执行java -classpath .;d:\iText.jar;d:\iTextAsian.jar; Chap0909