当前位置: 首页>>代码示例>>Java>>正文


Java Table.setConvert2pdfptable方法代码示例

本文整理汇总了Java中com.lowagie.text.Table.setConvert2pdfptable方法的典型用法代码示例。如果您正苦于以下问题:Java Table.setConvert2pdfptable方法的具体用法?Java Table.setConvert2pdfptable怎么用?Java Table.setConvert2pdfptable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.lowagie.text.Table的用法示例。


在下文中一共展示了Table.setConvert2pdfptable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.lowagie.text.Table; //导入方法依赖的package包/类
/**
 * A very simple Table example.
 * 
 */
@Test
public void main() throws Exception {
	// step 1: creation of a document-object
	Document document = new Document();
	// step 2:
	// we create a writer that listens to the document
	// and directs a PDF-stream to a file
	PdfWriter.getInstance(document, PdfTestBase.getOutputStream("MyFirstTable.pdf"));
	// step 3: we open the document
	document.open();
	// step 4: we create a table and add it to the document
	Table table = new Table(2, 2); // 2 rows, 2 columns
	table.addCell("0.0");
	table.addCell("0.1");
	table.addCell("1.0");
	table.addCell("1.1");
	document.add(table);
	document.add(new Paragraph("converted to PdfPTable:"));
	table.setConvert2pdfptable(true);
	document.add(table);

	// step 5: we close the document
	document.close();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:29,代码来源:MyFirstTableTest.java

示例2: main

import com.lowagie.text.Table; //导入方法依赖的package包/类
/**
 * A very simple PdfPTable example.
 * 
 */
@Test
public void main() throws Exception {
	// step 1: creation of a document-object
	Document document = new Document();
	// step 2:
	// we create a writer that listens to the document
	// and directs a PDF-stream to a file
	PdfWriter.getInstance(document, PdfTestBase.getOutputStream("imageTable.pdf"));
	// step 3: we open the document
	document.open();
	// step 4: we create a table and add it to the document
	Table table = new Table(2, 2); // 2 rows, 2 columns
	table.addCell(new Cell(Image.getInstance(PdfTestBase.RESOURCES_DIR + "otsoe.jpg")));
	table.addCell(new Cell(Image.getInstance(PdfTestBase.RESOURCES_DIR + "iText.gif")));
	Cell c1 = new Cell();
	c1.add(Image.getInstance(PdfTestBase.RESOURCES_DIR + "iText.gif"));
	table.addCell(c1);
	Cell c2 = new Cell();
	c2.add(Image.getInstance(PdfTestBase.RESOURCES_DIR + "otsoe.jpg"));
	table.addCell(c2);
	document.add(table);
	document.add(new Paragraph("converted to PdfPTable:"));
	table.setConvert2pdfptable(true);
	document.add(table);

	// step 5: we close the document
	document.close();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:33,代码来源:TableWithImageTest.java

示例3: main

import com.lowagie.text.Table; //导入方法依赖的package包/类
/**
 * A very simple Table example.
 * 
 * @param args
 *            no arguments needed
 */
public static void main(String[] args) {
	System.out.println("My first table");
	// step 1: creation of a document-object
	Document document = new Document();
	try {
		// step 2:
		// we create a writer that listens to the document
		// and directs a PDF-stream to a file
		PdfWriter.getInstance(document, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + "droidtext" + java.io.File.separator + "MyFirstTable.pdf"));
		// step 3: we open the document
		document.open();
		// step 4: we create a table and add it to the document
		Table table = new Table(2, 2); // 2 rows, 2 columns
		table.addCell("0.0");
		table.addCell("0.1");
		table.addCell("1.0");
		table.addCell("1.1");
		document.add(table);
		document.add(new Paragraph("converted to PdfPTable:"));
		table.setConvert2pdfptable(true);
		document.add(table);
	} catch (DocumentException de) {
		System.err.println(de.getMessage());
	} catch (IOException ioe) {
		System.err.println(ioe.getMessage());
	}
	// step 5: we close the document
	document.close();
}
 
开发者ID:fc-dream,项目名称:PDFTestForAndroid,代码行数:36,代码来源:MyFirstTable.java

示例4: main

import com.lowagie.text.Table; //导入方法依赖的package包/类
/**
	 * A very simple PdfPTable example.
	 * 
	 * @param args
	 *            no arguments needed
	 */
	public static void main(String[] args) {
		System.out.println("A table with Image");
		// step 1: creation of a document-object
		Document document = new Document();
		try {
			// step 2:
			// we create a writer that listens to the document
			// and directs a PDF-stream to a file
			PdfWriter.getInstance(document, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + "droidtext" + java.io.File.separator + "imageTable.pdf"));
			// step 3: we open the document
			document.open();
			// step 4: we create a table and add it to the document
			Table table = new Table(2, 2); // 2 rows, 2 columns
			//Can't use filename => use byte[] instead
//			table.addCell(new Cell(Image.getInstance("otsoe.jpg")));
			ByteArrayOutputStream stream = new ByteArrayOutputStream();
			Bitmap bitmap = BitmapFactory.decodeResource(PdfTestRunner.getActivity().getResources(), R.drawable.otsoe);
			bitmap.compress(Bitmap.CompressFormat.JPEG /* FileType */,
			                        100 /* Ratio */, stream);
			Image jpg = Image.getInstance(stream.toByteArray());
			table.addCell(new Cell(jpg));
			
			//Can't use filename => use byte[] instead
//			table.addCell(new Cell(Image.getInstance("iText.gif")));
			stream = new ByteArrayOutputStream();
			bitmap = BitmapFactory.decodeResource(PdfTestRunner.getActivity().getResources(), R.drawable.itext_gif);
			bitmap.compress(Bitmap.CompressFormat.PNG /* FileType */,
			                        100 /* Ratio */, stream);
			Image gif = Image.getInstance(stream.toByteArray());
			table.addCell(new Cell(gif));
			
			Cell c1 = new Cell();
			c1.add(gif);
			table.addCell(c1);
			Cell c2 = new Cell();
			c2.add(Image.getInstance(jpg));
			table.addCell(c2);
			document.add(table);
			document.add(new Paragraph("converted to PdfPTable:"));
			table.setConvert2pdfptable(true);
			document.add(table);
		} catch (DocumentException de) {
			System.err.println(de.getMessage());
		} catch (IOException ioe) {
			System.err.println(ioe.getMessage());
		}
		// step 5: we close the document
		document.close();
	}
 
开发者ID:fc-dream,项目名称:PDFTestForAndroid,代码行数:56,代码来源:TableWithImage.java


注:本文中的com.lowagie.text.Table.setConvert2pdfptable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。