List of usage examples for com.itextpdf.text Chunk getFont
public Font getFont()
Chunk
. From source file:com.chaschev.itext.ColumnTextBuilder.java
License:Apache License
public ColumnTextBuilder addTruncatedLine(Chunk chunk, boolean addEllipsis) { final float pixelsForEllipsis = 6; try {/*from w w w. ja va 2 s .c o 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); } }
From source file:com.github.wolfposd.imsqti2pdf.PDFCreator.java
License:Open Source License
private void fixFonts(Paragraph para) { for (Element element : para) { if (element instanceof Paragraph) { Paragraph p = (Paragraph) element; p.getFont().setSize(OVERALLFONTSIZE); fixFonts(p);//from w ww . java 2 s .c o m } else if (element instanceof Chunk) { Chunk c = (Chunk) element; c.getFont().setSize(OVERALLFONTSIZE); } else if (element instanceof List) { } else if (element instanceof PdfPTable) { PdfPTable table = (PdfPTable) element; for (Chunk c : table.getChunks()) { c.getFont().setSize(OVERALLFONTSIZE); } } else { // System.out.println(element); } } }
From source file:com.masscustsoft.service.ToPdf.java
License:Open Source License
private void applyFont(Chunk ch, Map it) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { ch.getFont().setSize(getSize(it)); ch.getFont().setStyle(getStyle(it)); ch.getFont().setColor(getColor(it, "color")); MapUtil.setIfFloat(it, "textRise", ch); Float skewAlpha = MapUtil.getFloat(it, "skewAlpha", null); Float skewBeta = MapUtil.getFloat(it, "skewBeta", null); if (skewAlpha != null && skewBeta != null) ch.setSkew(skewAlpha.floatValue(), skewBeta.floatValue()); MapUtil.setIfStr(it, "localDestination", ch); MapUtil.setIfStr(it, "localGoto", ch); }
From source file:com.vectorprint.report.itext.ItextHelper.java
License:Open Source License
public static float getTextHeight(Chunk c) { return c.getFont().getSize(); }
From source file:com.vectorprint.report.itext.style.stylers.Font.java
License:Open Source License
@Override public <E> E style(E text, Object data) throws VectorPrintException { com.itextpdf.text.Font f = getFont(); if (text instanceof Phrase) { ((Phrase) text).setFont(f);/*from w w w. ja v a 2s .co m*/ } else if (text instanceof Chunk) { ((Chunk) text).setFont(f); } if (text instanceof TextElementArray) { for (Object o : ((TextElementArray) text).getChunks()) { Chunk c = (Chunk) o; if (c.getFont().getFamily() == com.itextpdf.text.Font.FontFamily.UNDEFINED) { c.setFont(f); } } } return text; }
From source file:fll.util.PdfUtils.java
License:Open Source License
/** * Create a header cell for a table.//from w ww .j ava2 s. c o m */ public static PdfPCell createHeaderCell(final String text) throws BadElementException { final Chunk chunk = new Chunk(text); chunk.getFont().setStyle(Font.BOLD); final PdfPCell cell = createBasicCell(chunk); return cell; }