Java Code Examples for com.lowagie.text.pdf.PdfPCell#cloneNonPositionParameters()

The following examples show how to use com.lowagie.text.pdf.PdfPCell#cloneNonPositionParameters() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Cell.java    From itext2 with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Creates a PdfPCell based on this Cell object.
 * @return a PdfPCell
 * @throws BadElementException
 */
public PdfPCell createPdfPCell() throws BadElementException {
	if (rowspan > 1) throw new BadElementException("PdfPCells can't have a rowspan > 1");
	if (isTable()) return new PdfPCell(((Table)arrayList.get(0)).createPdfPTable());
	PdfPCell cell = new PdfPCell();
	cell.setVerticalAlignment(verticalAlignment);
	cell.setHorizontalAlignment(horizontalAlignment);
	cell.setColspan(colspan);
	cell.setUseBorderPadding(useBorderPadding);
	cell.setUseDescender(useDescender);
	cell.setLeading(getLeading(), 0);
	cell.cloneNonPositionParameters(this);
	cell.setNoWrap(getMaxLines() == 1);
	for (Iterator i = getElements(); i.hasNext(); ) {
           Element e = (Element)i.next();
           if (e.type() == Element.PHRASE || e.type() == Element.PARAGRAPH) {
               Paragraph p = new Paragraph((Phrase)e);
               p.setAlignment(horizontalAlignment);
               e = p;
           }
		cell.addElement(e);
	}
	return cell;
}
 
Example 2
Source File: TableBordersTest.java    From itext2 with GNU Lesser General Public License v3.0 6 votes vote down vote up
private static PdfPCell makeCell(String text, int vAlignment, int hAlignment, Font font, float leading,
		float padding, Rectangle borders, boolean ascender, boolean descender) {
	Paragraph p = new Paragraph(text, font);
	p.setLeading(leading);

	PdfPCell cell = new PdfPCell(p);
	cell.setLeading(leading, 0);
	cell.setVerticalAlignment(vAlignment);
	cell.setHorizontalAlignment(hAlignment);
	cell.cloneNonPositionParameters(borders);
	cell.setUseAscender(ascender);
	cell.setUseDescender(descender);
	cell.setUseBorderPadding(true);
	cell.setPadding(padding);
	return cell;
}
 
Example 3
Source File: Cell.java    From MesquiteCore with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Creates a PdfPCell based on this Cell object.
 * @return a PdfPCell
 * @throws BadElementException
 */
public PdfPCell createPdfPCell() throws BadElementException {
	if (rowspan > 1) throw new BadElementException("PdfPCells can't have a rowspan > 1");
	if (isTable()) return new PdfPCell(((Table)arrayList.get(0)).createPdfPTable());
	PdfPCell cell = new PdfPCell();
	cell.setVerticalAlignment(verticalAlignment);
	cell.setHorizontalAlignment(horizontalAlignment);
	cell.setColspan(colspan);
	cell.setUseBorderPadding(useBorderPadding);
	cell.setUseDescender(useDescender);
	cell.setLeading(leading(), 0);
	cell.cloneNonPositionParameters(this);
	for (Iterator i = getElements(); i.hasNext(); ) {
		cell.addElement((Element)i.next());
	}
	return cell;
}
 
Example 4
Source File: Cell.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Creates a PdfPCell based on this Cell object.
 * 
 * @return a PdfPCell
 * @throws BadElementException
 */
public PdfPCell createPdfPCell() throws BadElementException {
	if (rowspan > 1) {
		throw new BadElementException("PdfPCells can't have a rowspan > 1");
	}
	if (isTable()) {
		return new PdfPCell(((Table) arrayList.get(0)).createPdfPTable());
	}
	PdfPCell cell = new PdfPCell();
	cell.setVerticalAlignment(verticalAlignment);
	cell.setHorizontalAlignment(horizontalAlignment);
	cell.setColspan(colspan);
	cell.setUseBorderPadding(useBorderPadding);
	cell.setUseDescender(useDescender);
	cell.setLeading(getLeading(), 0);
	cell.cloneNonPositionParameters(this);
	cell.setNoWrap(getMaxLines() == 1);
	for (Iterator i = getElements(); i.hasNext();) {
		Element e = (Element) i.next();
		if (e.type() == Element.PHRASE || e.type() == Element.PARAGRAPH) {
			Paragraph p = new Paragraph((Phrase) e);
			p.setAlignment(horizontalAlignment);
			e = p;
		}
		cell.addElement(e);
	}
	return cell;
}