Snake Package; importar java.io.file; importar java.io.fileInputStream; importar java.io.fileOutputStream; importar java.io.ioException; importar java.io.inputStream; importar com.lowagie.text.document; importar com. lowagie.text.documentException; importar com.lowagie.text.font; importar com.lowagie.text.paragraph; importar com.lowagie.text.pdf.basefont; import com.lowagie.text.pdf.pdfwriter; classe pública Pdfutil { public static void printpdf (conteúdo da string) lança documentException, ioexception {document document = new document (); pdfwriter.getInstance (document, new FileOutputStream ("d: /demo.pdf"); "Stsong-Light", // "UnIgb-Ucs2-h", BaseFont.Not_Embedded); // Windows 自带的字体 BaseFont chinês = BaseFont.CreateFont ("C: /windows/fonts/simsun.ttc,1" , BaseFont.Identity_H, BaseFont.Embedded); Fonte Fonte = New Font (Chinese, 14, Font.Normal); document.addauthor ("Westdream"); document.addtitle ("test iText"); document.addsubject ("this é uma demonstração do iText "); document.addkeywords (" palavras -chave iText "); document.addcreator (" usando o iText "); document.open (); document.add (novo parágrafo (conteúdo, font)); document.close ( );} public static void main (string [] args) lança exceção {arquivo file = new File ("c: //users//zan//desktop//demo.txt"); byte [] bytes = new Byte [ (int) file.length ()]; inputStream input = new FileInputStream (file); input.read (bytes, 0, (int) file.length ()); printpdf (new string (bytes, "gbk")); }}