Paketschlange; import Java.io.file; Import Java.io.FileInputStream; Import Java.io.FileOutputStream; Import java.io.ioxception; import Java.io.inputStream; import com.lowagie.text.document; import com. lowagie.text.documentException; import com.lowagie.text.font; import com.lowagie.text.paragraph; import com.lowagie.text.pdf.baseFont; import com.lowagie.text.pdf.pdfwriter; öffentliche Klasse pdfutil {oder public static void printpdf (String -Inhalt) löst documentException, ioException {document document = new document (); "StSong-Light", // "unigb-ucs2-h", baseFont.not_embeded); // 使用 Windows 自带的字体 BaseFont Chinese = BaseFont.CreatEfont ("C: /windows/fonts/Simsun.ttc,1" , BaseFont.Identity_H, BaseFont.Embedded); Font Font = New Font (Chinese, 14, Font.Normal); document.addAuthor ("Westdream"); document.addtitle ("test itext"); document.addsubject ("This" This " ist eine ITEXT -Demo "); document.addKeywords (" itext keywords "); document.addCreator (" mit iText "); document.open (); document.add (neuer Absatz (Inhalt, Schriftart)); document.clos );} public static void main (String [] args) löst eine Ausnahme aus {Datei Datei = neue Datei ("c: //users/zan//desktop//demo.txt"); byte [] bytes = new byte [ (int) file.length ()]; inputStream input = new FileInputStream (Datei); input.read (Bytes, 0, (int) Datei.length ()); printpdf (neue String (Bytes, "GBK"); }}