当前位置: 首页>>代码示例>>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;未经允许,请勿转载。