关于在pdf文件中的中文字体显示

宋体 (TrueType) = SIMSUN.TTF

黑体 (TrueType) = simhei.ttf

楷体_GB2312 (TrueType) = simkai.ttf

仿宋_GB2312 (TrueType) = simfang.ttf

Arial (TrueType) = ARIAL.TTF

Arial 粗体 (TrueType) = ARIALBD.TTF

Arial 粗斜体 (TrueType) = ARIALBI.TTF

Arial 斜体 (TrueType) = ARIALI.TTF

Courier New 粗体 (TrueType) = COURBD.TTF

Courier New 粗斜体 (TrueType) = COURBI.TTF

Courier New 斜体 (TrueType) = COURI.TTF

Lucida Console (TrueType) = LUCON.TTF

Marlett (TrueType) = MARLETT.TTF

Tahoma = TAHOMA.TTF

Tahoma 粗体 (TrueType) = TAHOMABD.TTF

Times New Roman (TrueType) = TIMES.TTF

Times New Roman 粗体 (TrueType) = TIMESBD.TTF

Times New Roman 粗斜体 (TrueType) = TIMESBI.TTF

Times New Roman 斜体 (TrueType) = TIMESI.TTF

Modern (Plotter) = MODERN.FON

Comic Sans MS 粗体 (TrueType) = COMICBD.TTF

Verdana 粗体 (TrueType) = VERDANAB.TTF

Verdana 斜体 (TrueType) = VERDANAI.TTF

Verdana 粗斜体 (TrueType) = VERDANAZ.TTF

Basemic (TrueType) = BASEMIC_.TTF

Basemic Symbol (TrueType) = BASES___.TTF

Basemic Times (TrueType) = BASET___.TTF

Kingsoft Phonetic (TrueType) = Ksphonet.ttf

SerialNumber = dword:000b6bbc

MingLiU & PMingLiU (TrueType) = MINGLIU.TTC

方正舒体 (TrueType) = FZSTK.TTF

方正姚体 (TrueType) = FZYTK.TTF

隶书 (TrueType) = SIMLI.TTF

华文彩云 (TrueType) = STCAIYUN.TTF

华文细黑 (TrueType) = STXIHEI.TTF

华文行楷 (TrueType) = STXINGKA.TTF

华文新魏 (TrueType) = STXINWEI.TTF

华文中宋 (TrueType) = STZHONGS.TTF

幼圆 (TrueType) = SIMYOU.TTF

Arial Black (TrueType) = ARIBLK.TTF

Arial Narrow (TrueType) = ARIALN.TTF

Book Antiqua (TrueType) = BKANT.TTF

Bookman Old Style (TrueType) = BOOKOS.TTF

Century Gothic (TrueType) = GOTHIC.TTF

Comic Sans MS (TrueType) = COMIC.TTF

Courier New (TrueType) = COUR.TTF

Garamond (TrueType) = GARA.TTF

Haettenschweiler (TrueType) = HATTEN.TTF

Impact (TrueType) = IMPACT.TTF

Monotype Corsiva (TrueType) = MTCORSVA.TTF

MS Outlook (TrueType) = Outlook.TTF

Symbol (TrueType) = SYMBOL.TTF

Trebuchet MS (TrueType) = TREBUC.TTF

Verdana (TrueType) = VERDANA.TTF

Wingdings (TrueType) = WINGDING.TTF

Wingdings 2 (TrueType) = WINGDNG2.TTF

Wingdings 3 (TrueType) = WINGDNG3.TTF

Book Antiqua Bold (TrueType) = ANTQUAB.TTF

Book Antiqua Bold Italic (TrueType) = ANTQUABI.TTF

Book Antiqua Italic (TrueType) = ANTQUAI.TTF

Arial Black Italic (TrueType) = ARBLI___.TTF

Arial Bold (TrueType) = ARIALBD.TTF

Arial Bold Italic (TrueType) = ARIALBI.TTF

Arial Italic (TrueType) = ARIALI.TTF

Arial Narrow Bold (TrueType) = ARIALNB.TTF

Arial Narrow Bold Italic (TrueType) = ARIALNBI.TTF

Arial Narrow Italic (TrueType) = ARIALNI.TTF

Bookman Old Style Bold (TrueType) = BOOKOSB.TTF

Bookman Old Style Bold Italic (TrueType) = BOOKOSBI.TTF

Bookman Old Style Italic (TrueType) = BOOKOSI.TTF

Comic Sans MS Bold (TrueType) = COMICBD.TTF

Courier New Bold (TrueType) = COURBD.TTF

Courier New Bold Italic (TrueType) = COURBI.TTF

Courier New Italic (TrueType) = COURI.TTF

Garamond Bold (TrueType) = GARABD.TTF

Garamond Italic (TrueType) = GARAIT.TTF

Century Gothic Bold (TrueType) = GOTHICB.TTF

Century Gothic Bold Italic (TrueType) = GOTHICBI.TTF

Century Gothic Italic (TrueType) = GOTHICI.TTF

Tahoma (TrueType) = TAHOMA.TTF

Tahoma Bold (TrueType) = TAHOMABD.TTF

Times New Roman Bold (TrueType) = TIMESBD.TTF

Times New Roman Bold Italic (TrueType) = TIMESBI.TTF

Times New Roman Italic (TrueType) = TIMESI.TTF

Trebuchet MS Bold (TrueType) = TREBUCBD.TTF

Trebuchet MS Bold Italic (TrueType) = TREBUCBI.TTF

Trebuchet MS Italic (TrueType) = TREBUCIT.TTF

Verdana Bold (TrueType) = VERDANAB.TTF

Verdana Italic (TrueType) = VERDANAI.TTF

Verdana Bold Italic (TrueType) = VERDANAZ.TTF

Webdings (TrueType) = WEBDINGS.TTF

Tahoma (True Type) = tahoma.ttf 

OutputStream os = new FileOutputStream(outputFile);
		ITextRenderer renderer = new ITextRenderer();

		String content = openFile(inputFile);

		StringBuffer bf = new StringBuffer();
		bf.append("");
		bf.append(content);
		renderer.setDocumentFromString(content);
		// 必须有对应的字体 解决中文支持问题
		ITextFontResolver fontResolver = renderer.getFontResolver();
		fontResolver.addFont("C:/Windows/Fonts/SIMSUN.TTC", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
		// font-family:'Arial Unicode MS'"
		fontResolver.addFont("C:/Windows/Fonts/ARIALUNI.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); 
		fontResolver.addFont("C:/Windows/Fonts/SIMYOU.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
		fontResolver.flushFontFaceFonts();

		// 解决图片的相对路径问题
		renderer.getSharedContext().setBaseURL("file:/D:/");

		renderer.layout();
		renderer.createPDF(os);
		os.flush();
		os.close();

		return true;


你可能感兴趣的:(关于在pdf文件中的中文字体显示)