List of usage examples for com.itextpdf.text.pdf ColumnText duplicate
public static ColumnText duplicate(final ColumnText org)
org
. From source file:com.chaschev.itext.ColumnTextBuilder.java
License:Apache License
public ColumnTextBuilder dup() { final ColumnTextBuilder b = new ColumnTextBuilder(iTextBuilder); b.simpleColumnRectangle = new Rectangle(simpleColumnRectangle); b.columnText = ColumnText.duplicate(columnText); b.pageBottom = pageBottom;//w w w . ja va 2 s . c o m b.pageTop = pageTop; return b; }
From source file:com.chaschev.itext.ColumnTextBuilder.java
License:Apache License
public ColumnTextBuilder addTruncatedLine(Chunk chunk, boolean addEllipsis) { final float pixelsForEllipsis = 6; try {//from ww w .j a v a 2 s . co m ColumnText dup = ColumnText.duplicate(columnText); final Rectangle oneLineRectangle = new Rectangle(simpleColumnRectangle); oneLineRectangle.setTop(dup.getYLine()); final float fontHeight = calcApproximateFontHeight(chunk.getFont()) * 1.6f; oneLineRectangle.setBottom(dup.getYLine() - fontHeight); if (addEllipsis) { oneLineRectangle.setRight(oneLineRectangle.getRight() - pixelsForEllipsis); } dup.setSimpleColumn(oneLineRectangle); dup.addText(chunk); final int status = dup.go(); float yLine; if (addEllipsis && ColumnText.hasMoreText(status)) { oneLineRectangle.setLeft(dup.getLastX() + 2); oneLineRectangle.setRight(oneLineRectangle.getRight() + pixelsForEllipsis * 2); dup = ColumnText.duplicate(dup); dup.setSimpleColumn(oneLineRectangle); final Chunk ellipses = new Chunk("...\n", chunk.getFont()); dup.setText(new Phrase(ellipses)); dup.go(); yLine = dup.getYLine(); } else { yLine = dup.getYLine(); } setYLine(yLine); return this; } catch (DocumentException e) { throw Exceptions.runtime(e); } }