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

The following examples show how to use com.lowagie.text.pdf.PdfPCell#setUseDescender() . 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;
}
 
Example 5
Source File: IncCell.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/** Creates a new instance of IncCell */
public IncCell(String tag, ChainedProperties props) {
    cell = new PdfPCell((Phrase)null);
    String value = props.getProperty("colspan");
    if (value != null)
        cell.setColspan(Integer.parseInt(value));
    value = props.getProperty("align");
    if (tag.equals("th"))
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    if (value != null) {
        if ("center".equalsIgnoreCase(value))
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        else if ("right".equalsIgnoreCase(value))
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        else if ("left".equalsIgnoreCase(value))
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        else if ("justify".equalsIgnoreCase(value))
            cell.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
    }
    value = props.getProperty("valign");
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    if (value != null) {
        if ("top".equalsIgnoreCase(value))
            cell.setVerticalAlignment(Element.ALIGN_TOP);
        else if ("bottom".equalsIgnoreCase(value))
            cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
    }
    value = props.getProperty("border");
    float border = 0;
    if (value != null)
        border = Float.parseFloat(value);
    cell.setBorderWidth(border);
    value = props.getProperty("cellpadding");
    if (value != null)
        cell.setPadding(Float.parseFloat(value));
    cell.setUseDescender(true);
    value = props.getProperty("bgcolor");
    cell.setBackgroundColor(Markup.decodeColor(value));
}
 
Example 6
Source File: IncCell.java    From itext2 with GNU Lesser General Public License v3.0 5 votes vote down vote up
/** Creates a new instance of IncCell */
public IncCell(String tag, ChainedProperties props) {
    cell = new PdfPCell((Phrase)null);
    String value = props.getProperty("colspan");
    if (value != null)
        cell.setColspan(Integer.parseInt(value));
    value = props.getProperty("align");
    if (tag.equals("th"))
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    if (value != null) {
        if ("center".equalsIgnoreCase(value))
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        else if ("right".equalsIgnoreCase(value))
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        else if ("left".equalsIgnoreCase(value))
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        else if ("justify".equalsIgnoreCase(value))
            cell.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
    }
    value = props.getProperty("valign");
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    if (value != null) {
        if ("top".equalsIgnoreCase(value))
            cell.setVerticalAlignment(Element.ALIGN_TOP);
        else if ("bottom".equalsIgnoreCase(value))
            cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
    }
    value = props.getProperty("border");
    float border = 0;
    if (value != null)
        border = Float.parseFloat(value);
    cell.setBorderWidth(border);
    value = props.getProperty("cellpadding");
    if (value != null)
        cell.setPadding(Float.parseFloat(value));
    cell.setUseDescender(true);
    value = props.getProperty("bgcolor");
    cell.setBackgroundColor(Markup.decodeColor(value));
}
 
Example 7
Source File: SimpleCell.java    From gcs with Mozilla Public License 2.0 4 votes vote down vote up
/**
 * Creates a PdfPCell with these attributes.
 * 
 * @param rowAttributes
 * @return a PdfPCell based on these attributes.
 */
public PdfPCell createPdfPCell(SimpleCell rowAttributes) {
	PdfPCell cell = new PdfPCell();
	cell.setBorder(NO_BORDER);
	SimpleCell tmp = new SimpleCell(CELL);
	tmp.setSpacing_left(spacing_left);
	tmp.setSpacing_right(spacing_right);
	tmp.setSpacing_top(spacing_top);
	tmp.setSpacing_bottom(spacing_bottom);
	tmp.cloneNonPositionParameters(rowAttributes);
	tmp.softCloneNonPositionParameters(this);
	cell.setCellEvent(tmp);
	cell.setHorizontalAlignment(rowAttributes.horizontalAlignment);
	cell.setVerticalAlignment(rowAttributes.verticalAlignment);
	cell.setUseAscender(rowAttributes.useAscender);
	cell.setUseBorderPadding(rowAttributes.useBorderPadding);
	cell.setUseDescender(rowAttributes.useDescender);
	cell.setColspan(colspan);
	if (horizontalAlignment != Element.ALIGN_UNDEFINED) {
		cell.setHorizontalAlignment(horizontalAlignment);
	}
	if (verticalAlignment != Element.ALIGN_UNDEFINED) {
		cell.setVerticalAlignment(verticalAlignment);
	}
	if (useAscender) {
		cell.setUseAscender(useAscender);
	}
	if (useBorderPadding) {
		cell.setUseBorderPadding(useBorderPadding);
	}
	if (useDescender) {
		cell.setUseDescender(useDescender);
	}
	float p;
	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;
	}
	p = padding_left;
	if (Float.isNaN(p)) {
		p = 0f;
	}
	cell.setPaddingLeft(p + sp_left);
	p = padding_right;
	if (Float.isNaN(p)) {
		p = 0f;
	}
	cell.setPaddingRight(p + sp_right);
	p = padding_top;
	if (Float.isNaN(p)) {
		p = 0f;
	}
	cell.setPaddingTop(p + sp_top);
	p = padding_bottom;
	if (Float.isNaN(p)) {
		p = 0f;
	}
	cell.setPaddingBottom(p + sp_bottom);
	Element element;
	for (Iterator i = content.iterator(); i.hasNext();) {
		element = (Element) i.next();
		cell.addElement(element);
	}
	return cell;
}
 
Example 8
Source File: SimpleCell.java    From itext2 with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Creates a PdfPCell with these attributes.
 * @param rowAttributes
 * @return a PdfPCell based on these attributes.
 */
public PdfPCell createPdfPCell(SimpleCell rowAttributes) {
	PdfPCell cell = new PdfPCell();
	cell.setBorder(NO_BORDER);
	SimpleCell tmp = new SimpleCell(CELL);
	tmp.setSpacing_left(spacing_left);
	tmp.setSpacing_right(spacing_right);
	tmp.setSpacing_top(spacing_top);
	tmp.setSpacing_bottom(spacing_bottom);
	tmp.cloneNonPositionParameters(rowAttributes);
	tmp.softCloneNonPositionParameters(this);
	cell.setCellEvent(tmp);
	cell.setHorizontalAlignment(rowAttributes.horizontalAlignment);
	cell.setVerticalAlignment(rowAttributes.verticalAlignment);
	cell.setUseAscender(rowAttributes.useAscender);
	cell.setUseBorderPadding(rowAttributes.useBorderPadding);
	cell.setUseDescender(rowAttributes.useDescender);
	cell.setColspan(colspan);
	if (horizontalAlignment != Element.ALIGN_UNDEFINED)
		cell.setHorizontalAlignment(horizontalAlignment);
	if (verticalAlignment != Element.ALIGN_UNDEFINED)
		cell.setVerticalAlignment(verticalAlignment);
	if (useAscender)
		cell.setUseAscender(useAscender);
	if (useBorderPadding)
		cell.setUseBorderPadding(useBorderPadding);
	if (useDescender)
		cell.setUseDescender(useDescender);
	float p;
	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;
	p = padding_left;
	if (Float.isNaN(p)) p = 0f; 
	cell.setPaddingLeft(p + sp_left);
	p = padding_right;
	if (Float.isNaN(p)) p = 0f; 
	cell.setPaddingRight(p + sp_right);
	p = padding_top;
	if (Float.isNaN(p)) p = 0f; 
	cell.setPaddingTop(p + sp_top);
	p = padding_bottom;
	if (Float.isNaN(p)) p = 0f; 
	cell.setPaddingBottom(p + sp_bottom);
	Element element;
	for (Iterator i = content.iterator(); i.hasNext(); ) {
		element = (Element)i.next();
		cell.addElement(element);
	}
	return cell;
}