當前位置: 首頁>>代碼示例>>Java>>正文


Java BaseFont.HELVETICA屬性代碼示例

本文整理匯總了Java中com.lowagie.text.pdf.BaseFont.HELVETICA屬性的典型用法代碼示例。如果您正苦於以下問題:Java BaseFont.HELVETICA屬性的具體用法?Java BaseFont.HELVETICA怎麽用?Java BaseFont.HELVETICA使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在com.lowagie.text.pdf.BaseFont的用法示例。


在下文中一共展示了BaseFont.HELVETICA屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

/**
 * Registering fonts with the fontfactory.
 */
@Test
public void main() throws Exception {


	String liberationPath = "src/test/resources/liberation-fonts-ttf/";
	FontFactory.register(liberationPath + "LiberationMono-Regular.ttf");
	FontFactory.register(liberationPath + "LiberationSans-Regular.ttf");
	FontFactory.register(liberationPath + "LiberationSerif-Regular.ttf");

	// step 1: creation of a document-object
	Document document = new Document();

	// step 2: creation of the writer
	PdfWriter.getInstance(document, PdfTestBase.getOutputStream("registerfont.pdf"));

	// step 3: we open the document
	document.open();

	// step 4: we add content to the document
	Font font0 = FontFactory.getFont(BaseFont.HELVETICA, BaseFont.WINANSI, 12);
	String text0 = "This is the quite popular built in font '" + BaseFont.HELVETICA + "'.";
	document.add(new Paragraph(text0, font0));
	Font font1 = FontFactory.getFont("LiberationMono", BaseFont.WINANSI, 12);
	String text1 = "This is the quite popular True Type font 'LiberationMono'.";
	document.add(new Paragraph(text1, font1));
	Font font2 = FontFactory.getFont("LiberationSans-Bold", BaseFont.WINANSI, 12);
	String text2 = "This is the quite popular True Type font 'LiberationSans-Bold'.";
	document.add(new Paragraph(text2, font2));
	Font font3 = FontFactory.getFont("LiberationSerif", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 12);
	String text3 = "\u5951\u7d04\u8005\u4f4f\u6240\u30e9\u30a4\u30f3\uff11";
	document.add(new Paragraph(text3, font3));
	BufferedWriter out = new BufferedWriter(new OutputStreamWriter(PdfTestBase.getOutputStream("registered.txt")));
	out.write("These fonts were registered at the FontFactory:\r\n");
	for (Iterator i = FontFactory.getRegisteredFonts().iterator(); i.hasNext();) {
		out.write((String) i.next());
		out.write("\r\n");
	}
	out.write("\r\n\r\nThese are the families these fonts belong to:\r\n");
	for (Iterator i = FontFactory.getRegisteredFamilies().iterator(); i.hasNext();) {
		out.write((String) i.next());
		out.write("\r\n");
	}
	out.flush();
	out.close();

	// step 5: we close the document
	document.close();

}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:52,代碼來源:RegisterFontTest.java


注:本文中的com.lowagie.text.pdf.BaseFont.HELVETICA屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。