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


Java PdfPTable类代码示例

本文整理汇总了Java中com.lowagie.text.pdf.PdfPTable的典型用法代码示例。如果您正苦于以下问题:Java PdfPTable类的具体用法?Java PdfPTable怎么用?Java PdfPTable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: write

import com.lowagie.text.pdf.PdfPTable; //导入依赖的package包/类
public void write(PDFDocument document, PdfPTable tabla) throws DocumentException {
	com.lowagie.text.List list = new com.lowagie.text.List(false,10f);
	list.setListSymbol(new Chunk("\u2022"));

	PdfPCell cell = new PdfPCell();
	
	if(!titulo.equals(""))
	{
	   cell.addElement(new Phrase(titulo,document.getContext().getDefaultFont()));
	}

	for(int i=0; i<campos.size(); i++)
	{
		list.add(new ListItem((String)campos.get(i),document.getContext().getDefaultFont()));
	}
	
	cell.addElement(list);
	cell.setPaddingLeft(30f);
	cell.setBorder(Rectangle.LEFT | Rectangle.RIGHT);
	cell.setColspan(2);
	tabla.addCell(cell);
	
}
 
开发者ID:GovernIB,项目名称:sistra,代码行数:24,代码来源:Lista.java

示例2: insertTable_TextRow

import com.lowagie.text.pdf.PdfPTable; //导入依赖的package包/类
private void insertTable_TextRow( PdfWriter writer, PdfPTable mainTable, String text, Font font )
{
    boolean hasBorder = false;

    // Add Organization ID/Period textfield
    // Create A table to add for each group AT HERE
    PdfPTable table = new PdfPTable( 1 );
    table.setHorizontalAlignment( Element.ALIGN_LEFT );

    addCell_Text( table, PdfDataEntryFormUtil.getPdfPCell( hasBorder ), text, Element.ALIGN_LEFT, font );

    // Add to the main table
    PdfPCell cell_withInnerTable = new PdfPCell( table );

    cell_withInnerTable.setBorder( Rectangle.NO_BORDER );

    mainTable.addCell( cell_withInnerTable );
}
 
开发者ID:ehatle,项目名称:AgileAlligators,代码行数:19,代码来源:DefaultPdfDataEntryFormService.java

示例3: onEndPage

import com.lowagie.text.pdf.PdfPTable; //导入依赖的package包/类
@Override
public void onEndPage(PdfWriter writer, Document document) {
    try {
        Rectangle page = document.getPageSize();
        PdfPTable footer = new PdfPTable(1);
        footer.setWidthPercentage(100);
        footer.setSpacingBefore(20);
        PdfPCell footerPageNocell = new PdfPCell(new Paragraph(fontFamilySelector.process(messageSource.getMessage("hrms.payroll.computer.generated.payslip.not.require.signature", null, this.locale), FontContext.REGULAR_NORMAL_TIMES_NEW_ROMAN)));
        footerPageNocell.setBorder(0);
        footerPageNocell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        footer.addCell(footerPageNocell);
        footer.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
        footer.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin()+2 , writer.getDirectContent());

    } catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
 
开发者ID:mobilipia,项目名称:Deskera-HRMS,代码行数:19,代码来源:ExportSalarySlipService.java

示例4: onEndPage

import com.lowagie.text.pdf.PdfPTable; //导入依赖的package包/类
@Override
public void onEndPage(PdfWriter writer, Document document) {
    try {
        Rectangle page = document.getPageSize();
        PdfPTable footer = new PdfPTable(1);
        footer.setWidthPercentage(100);
        footer.setSpacingBefore(20);
        String FootPager = String.valueOf(document.getPageNumber());//current page no
        PdfPCell footerPageNocell = new PdfPCell(new Phrase(FootPager, fontSmallBold));
        footerPageNocell.setBorder(0);
        footerPageNocell.setPaddingBottom(5);
        footerPageNocell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        footer.addCell(footerPageNocell);
        footer.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
        footer.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin() - 5, writer.getDirectContent());

    } catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
 
开发者ID:mobilipia,项目名称:Deskera-HRMS,代码行数:21,代码来源:AppraisalDetails.java

示例5: buildPdfDocument

import com.lowagie.text.pdf.PdfPTable; //导入依赖的package包/类
@Override
protected void buildPdfDocument(Map<String, Object> model, Document document, PdfWriter writer,
		HttpServletRequest request, HttpServletResponse response) throws Exception {

	List<Book> books = (List<Book>) model.get("book");

	PdfPTable table = new PdfPTable(3);
	table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
	table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
	table.getDefaultCell().setBackgroundColor(Color.lightGray);

	table.addCell("Book Name");
	table.addCell("Author Name");
	table.addCell("Price");

	for (Book book : books) {
		table.addCell(book.getBookName());
		table.addCell(book.getAuthor());
		table.addCell("" + book.getPrice());
	}
	document.add(table);

}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-5.0,代码行数:24,代码来源:PdfView.java

示例6: cellLayout

import com.lowagie.text.pdf.PdfPTable; //导入依赖的package包/类
/**
 * @see com.lowagie.text.pdf.PdfPCellEvent#cellLayout(com.lowagie.text.pdf.PdfPCell, com.lowagie.text.Rectangle, com.lowagie.text.pdf.PdfContentByte[])
 */
public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) {
	float sp_left = spacing_left;
	if (Float.isNaN(sp_left)) sp_left = 0f;
	float sp_right = spacing_right;
	if (Float.isNaN(sp_right)) sp_right = 0f;
	float sp_top = spacing_top;
	if (Float.isNaN(sp_top)) sp_top = 0f;
	float sp_bottom = spacing_bottom;
	if (Float.isNaN(sp_bottom)) sp_bottom = 0f;
	Rectangle rect = new Rectangle(position.getLeft(sp_left), position.getBottom(sp_bottom), position.getRight(sp_right), position.getTop(sp_top));
	rect.cloneNonPositionParameters(this);
	canvases[PdfPTable.BACKGROUNDCANVAS].rectangle(rect);
	rect.setBackgroundColor(null);
	canvases[PdfPTable.LINECANVAS].rectangle(rect);
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:19,代码来源:SimpleCell.java

示例7: onEndPage

import com.lowagie.text.pdf.PdfPTable; //导入依赖的package包/类
/**
 * @see com.lowagie.text.pdf.PdfPageEventHelper#onEndPage(com.lowagie.text.pdf.PdfWriter,
 *      com.lowagie.text.Document)
 */
public void onEndPage(PdfWriter writer, Document document) {
	try {
		Rectangle page = document.getPageSize();
		PdfPTable head = new PdfPTable(3);
		for (int k = 1; k <= 6; ++k)
			head.addCell("head " + k);
		head.setTotalWidth(page.getWidth() - document.leftMargin()
				- document.rightMargin());
		head.writeSelectedRows(
				0,
				-1,
				document.leftMargin(),
				page.getHeight() - document.topMargin()
						+ head.getTotalHeight(), writer.getDirectContent());
		PdfPTable foot = new PdfPTable(3);
		for (int k = 1; k <= 6; ++k)
			foot.addCell("foot " + k);
		foot.setTotalWidth(page.getWidth() - document.leftMargin()
				- document.rightMargin());
		foot.writeSelectedRows(0, -1, document.leftMargin(),
				document.bottomMargin(), writer.getDirectContent());
	} catch (Exception e) {
		throw new ExceptionConverter(e);
	}
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:30,代码来源:EndPageTest.java

示例8: main

import com.lowagie.text.pdf.PdfPTable; //导入依赖的package包/类
/**
 * A cell with an image.
 * 
 */
@Test
public void main() throws Exception {

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

	// step 2:
	PdfWriter.getInstance(document, PdfTestBase.getOutputStream("ImageCell.pdf"));

	// step 3: we open the document
	document.open();
	Image image = Image.getInstance(PdfTestBase.RESOURCES_DIR + "otsoe.jpg");
	float[] widths = { 1f, 4f };
	PdfPTable table = new PdfPTable(widths);
	table.addCell("This is my dog");
	table.addCell(image);
	table.addCell("This two");
	table.addCell(new PdfPCell(image, true));
	table.addCell("This three");
	table.addCell(new PdfPCell(image, false));
	document.add(table);

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

示例9: tableLayout

import com.lowagie.text.pdf.PdfPTable; //导入依赖的package包/类
/**
 * @see com.lowagie.text.pdf.PdfPTableEvent#tableLayout(com.lowagie.text.pdf.PdfPTable,
 *      float[][], float[], int, int, com.lowagie.text.pdf.PdfContentByte[])
 */
public void tableLayout(PdfPTable table, float[][] width, float[] height, int headerRows, int rowStart,
		PdfContentByte[] canvases) {
	float widths[] = width[0];
	float x1 = widths[0];
	float x2 = widths[widths.length - 1];
	float y1 = height[0];
	float y2 = height[height.length - 1];
	PdfContentByte canvas = canvases[PdfPTable.LINECANVAS];
	canvas.setRGBColorStroke(0x00, 0x00, 0xFF);
	canvas.rectangle(x1, y1, x2 - x1, y2 - y1);
	canvas.stroke();
	canvas.resetRGBColorStroke();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:18,代码来源:FloatingBoxesTest.java

示例10: cellLayout

import com.lowagie.text.pdf.PdfPTable; //导入依赖的package包/类
/**
 * @see com.lowagie.text.pdf.PdfPCellEvent#cellLayout(com.lowagie.text.pdf.PdfPCell,
 *      com.lowagie.text.Rectangle, com.lowagie.text.pdf.PdfContentByte[])
 */
public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) {
	float x1 = position.getLeft() + 2;
	float x2 = position.getRight() - 2;
	float y1 = position.getTop() - 2;
	float y2 = position.getBottom() + 2;
	PdfContentByte canvas = canvases[PdfPTable.LINECANVAS];
	canvas.setRGBColorStroke(0xFF, 0x00, 0x00);
	canvas.rectangle(x1, y1, x2 - x1, y2 - y1);
	canvas.stroke();
	canvas.resetRGBColorStroke();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:16,代码来源:FloatingBoxesTest.java

示例11: main

import com.lowagie.text.pdf.PdfPTable; //导入依赖的package包/类
/**
 * Break a large table up into several smaller tables for memory management
 * purposes.
 * 
 */
@Test
public void main() throws Exception {
	// step1
	Document document = new Document(PageSize.A4, 10, 10, 10, 10);
	// step2
	PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("SplitTable.pdf"));
	// step3
	document.open();
	// step4

	PdfContentByte cb = writer.getDirectContent();
	PdfPTable table = new PdfPTable(10);
	for (int k = 1; k <= 100; ++k) {
		table.addCell("The number " + k);
	}
	table.setTotalWidth(800);
	table.writeSelectedRows(0, 5, 0, -1, 50, 650, cb);
	document.newPage();
	table.writeSelectedRows(5, -1, 0, -1, 50, 650, cb);
	document.close();

	// step5
	document.close();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:30,代码来源:SplitTableTest.java

示例12: writeColumns

import com.lowagie.text.pdf.PdfPTable; //导入依赖的package包/类
private void writeColumns(PDFDocument document, PdfPTable tb)
	{
		PdfPTable tabla = new PdfPTable(anchoColumnas);		
		tabla.setWidthPercentage(100);
//		this.tabla.setSplitRows(true);
		
		Font font = document.getContext().getDefaultFont();
		PdfPCell cell;
		cell = createCell("",Rectangle.LEFT | Rectangle.RIGHT);
		tabla.addCell(cell);
		for(int i=0; i<columnas.size(); i++)
		{
			cell = createCell((String)columnas.get(i),document.getContext().getColor(204,204,204),
					  Rectangle.ALIGN_CENTER,font);
			tabla.addCell(cell);
		}
		cell = createCell("",Rectangle.LEFT | Rectangle.RIGHT);
		tabla.addCell(cell);
		addTabla(tb,tabla);
	}
 
开发者ID:GovernIB,项目名称:sistra,代码行数:21,代码来源:Tabla.java

示例13: writeCampos

import com.lowagie.text.pdf.PdfPTable; //导入依赖的package包/类
private void writeCampos(PDFDocument document, PdfPTable tb)
{
	PdfPTable tabla = new PdfPTable(anchoColumnas);
	PdfPCell cell;
	tabla.setWidthPercentage(100);
	Font font = document.getContext().getDefaultFont();
	for(int i=0; i<campos.size();i++)
	{
		cell = createCell("",Rectangle.LEFT | Rectangle.RIGHT);
		tabla.addCell(cell);
		Vector cp = (Vector)campos.get(i);
		for(int j=0; j<cp.size(); j++)
		{
			cell = createCell((String)cp.get(j),font);
			tabla.addCell(cell);
		}
		cell = createCell("",Rectangle.LEFT | Rectangle.RIGHT);
		tabla.addCell(cell);
	}
	addTabla(tb,tabla);
}
 
开发者ID:GovernIB,项目名称:sistra,代码行数:22,代码来源:Tabla.java

示例14: createNeedHeader

import com.lowagie.text.pdf.PdfPTable; //导入依赖的package包/类
private PdfPTable createNeedHeader(String name) throws DocumentException {
	Font whiteFont = new Font(Font.HELVETICA,14,Font.BOLD,Color.WHITE);
	PdfPTable table = new PdfPTable(3);
	table.setWidthPercentage(100);
	table.setWidths(new float[]{0.10f,0.20f,0.70f});
	PdfPCell emptyCell = new PdfPCell();
	emptyCell.setBorder(0);
	table.addCell(emptyCell);

	PdfPCell headerCell = new PdfPCell();
	headerCell.setColspan(2);
	headerCell.setPhrase(new Phrase(name,whiteFont));
	headerCell.setHorizontalAlignment(Element.ALIGN_CENTER);
	headerCell.setBackgroundColor(Color.LIGHT_GRAY);
	table.addCell(headerCell);
	return table;
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:18,代码来源:SummaryOfActionsAndCommentsReportGenerator.java

示例15: onEndPage

import com.lowagie.text.pdf.PdfPTable; //导入依赖的package包/类
/**
 * @see com.lowagie.text.pdf.PdfPageEventHelper#onEndPage(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document)
 */
public void onEndPage(PdfWriter writer, Document document) {
    try {
        Rectangle page = document.getPageSize();

        if (headerFooterPolicy.getHeader(writer.getPageNumber())!=null) {
         Hdr hdr = headerFooterPolicy.getHeader(writer.getPageNumber()).getJaxbElement();
         PdfPTable head = new PdfPTable(1); // num cols	            
         // TODO - no cell borders
         traverseBlockLevelContent( hdr.getEGBlockLevelElts(), head);
         head.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
         head.writeSelectedRows(0, -1, document.leftMargin(), page.getHeight() - document.topMargin() + head.getTotalHeight(),
             writer.getDirectContent());
        }
        
        if (headerFooterPolicy.getFooter(writer.getPageNumber())!=null) {
         Ftr ftr = headerFooterPolicy.getFooter(writer.getPageNumber()).getJaxbElement();	            
         PdfPTable foot = new PdfPTable(1);
         traverseBlockLevelContent( ftr.getEGBlockLevelElts(), foot);
         foot.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
         foot.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin(),
             writer.getDirectContent());
        }
    }
    catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
 
开发者ID:plutext,项目名称:docx4j-export-FO,代码行数:31,代码来源:Conversion.java


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