/** * Adds a <CODE>Chunk</CODE> to the current text array. Will not have any * effect if addElement() was called before. * * @param chunk the text */ public void addText(final Chunk chunk) { if (chunk == null || composite) { return; } addText(new Phrase(chunk)); }
/** * Adds a <CODE>Chunk</CODE> to the current text array. Will not have any * effect if addElement() was called before. * * @param chunk the text */ public void addText(final Chunk chunk) { if (chunk == null || composite) { return; } addText(new Phrase(chunk)); }
/** * Constructs a <CODE>PdfPCell</CODE> with a <CODE>Phrase</CODE>. The * default padding is 2. * * @param phrase the text */ public PdfPCell(Phrase phrase) { super(0, 0, 0, 0); borderWidth = 0.5f; border = BOX; column.addText(this.phrase = phrase); column.setLeading(0, 1); }
public ColumnText createColumn(PdfContentByte cb, int i, String la, Rectangle rect) throws IOException { ColumnText ct = new ColumnText(cb); ct.setSimpleColumn(rect); Phrase p = createPhrase(String.format("resources/text/liber1_%s_%s.txt", i, la)); ct.addText(p); return ct; }
/** * Constructs a <CODE>PdfPCell</CODE> with a <CODE>Phrase</CODE>. The * default padding is 2. * * @param phrase the text */ public PdfPCell(Phrase phrase) { super(0, 0, 0, 0); borderWidth = 0.5f; border = BOX; column.addText(this.phrase = phrase); column.setLeading(0, 1); }
/** * Simplified method for rectangular columns. * * @param phrase a <CODE>Phrase</CODE> * @param llx the lower left x corner * @param lly the lower left y corner * @param urx the upper right x corner * @param ury the upper right y corner * @param leading the leading * @param alignment the column alignment */ public void setSimpleColumn(final Phrase phrase, final float llx, final float lly, final float urx, final float ury, final float leading, final int alignment) { addText(phrase); setSimpleColumn(llx, lly, urx, ury, leading, alignment); }
/** * Simplified method for rectangular columns. * * @param phrase a <CODE>Phrase</CODE> * @param llx the lower left x corner * @param lly the lower left y corner * @param urx the upper right x corner * @param ury the upper right y corner * @param leading the leading * @param alignment the column alignment */ public void setSimpleColumn(final Phrase phrase, final float llx, final float lly, final float urx, final float ury, final float leading, final int alignment) { addText(phrase); setSimpleColumn(llx, lly, urx, ury, leading, alignment); }
class MyPdfPTableEvent implements PdfPTableEvent { public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) { } public void tableLayout(PdfPTable table, float[][] widths, float[] heights, int headerRows, int rowStart, PdfContentByte[] canvases) { ColumnText ct = new ColumnText(canvases[PdfPTable.TEXTCANVAS]); for (int i = 1; i < widths[1].length; i++) { Rectangle position = new Rectangle(widths[1][i - 1], heights[1], widths[1][i], heights[2]); ct.setSimpleColumn(position); ct.addText(new Phrase("This inner table header will always be repeated")); try { ct.go(); } catch (DocumentException ex) { } } } }
Phrase p = new Phrase("This text is added at the top of the column."); ColumnText ct = new ColumnText(cb); ct.setSimpleColumn(rect); ct.setUseAscender(true); ct.addText(p); ct.go();
Image dog = Image.getInstance(DOG); Image fox = Image.getInstance(FOX); Phrase p = new Phrase("quick brown fox jumps over the lazy dog."); p.add("Or, to say it in a more colorful way: quick brown "); p.add(new Chunk(fox, 0, 0, true)); p.add(" jumps over the lazy "); p.add(new Chunk(dog, 0, 0, true)); p.add("."); ColumnText ct = new ColumnText(writer.getDirectContent()); ct.setSimpleColumn(new Rectangle(50, 600, 400, 800)); ct.addText(p); ct.go();
public void manipulatePdf(String src, String dest) throws IOException, DocumentException { PdfReader reader = new PdfReader(src); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest)); PdfContentByte canvas = stamper.getOverContent(1); Font bold = new Font(FontFamily.HELVETICA, 12, Font.BOLD); Chunk chunk = new Chunk("The Best iText Questions on StackOverflow", bold); chunk.setAnchor("http://pages.itextpdf.com/ebook-stackoverflow-questions.html"); Phrase p = new Phrase("Download "); p.add(chunk); p.add(" and discover more than 200 questions and answers."); ColumnText ct = new ColumnText(canvas); ct.setSimpleColumn(36, 700, 559, 750); ct.addText(p); ct.go(); stamper.close(); reader.close(); }
/** * Gets the width that the line will occupy after writing. Only the width of * the first line is returned. * * @param phrase the <CODE>Phrase</CODE> containing the line * @param runDirection the run direction * @param arabicOptions the options for the arabic shaping * @return the width of the line */ public static float getWidth(final Phrase phrase, final int runDirection, final int arabicOptions) { ColumnText ct = new ColumnText(null); ct.addText(phrase); ct.addWaitingPhrase(); PdfLine line = ct.bidiLine.processLine(0, 20000, Element.ALIGN_LEFT, runDirection, arabicOptions, 0, 0, 0); if (line == null) { return 0; } else { return 20000 - line.widthLeft(); } }
/** * Gets the width that the line will occupy after writing. Only the width of * the first line is returned. * * @param phrase the <CODE>Phrase</CODE> containing the line * @param runDirection the run direction * @param arabicOptions the options for the arabic shaping * @return the width of the line */ public static float getWidth(final Phrase phrase, final int runDirection, final int arabicOptions) { ColumnText ct = new ColumnText(null); ct.addText(phrase); ct.addWaitingPhrase(); PdfLine line = ct.bidiLine.processLine(0, 20000, Element.ALIGN_LEFT, runDirection, arabicOptions, 0, 0, 0); if (line == null) { return 0; } else { return 20000 - line.widthLeft(); } }
ct.setSimpleColumn(rect); ct.setUseAscender(useAscender); ct.addText(p); ct.go();
public void manipulatePdf(String src, String dest) throws IOException, DocumentException { PdfReader reader = new PdfReader(src); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest)); AffineTransform transform = AffineTransform.getRotateInstance(Math.PI / 6); stamper.getWriter().setPageEvent(new AddAnnotation(stamper, transform)); PdfContentByte canvas = stamper.getOverContent(1); Font bold = new Font(FontFamily.HELVETICA, 12, Font.BOLD); Chunk chunk = new Chunk("The Best iText Questions on StackOverflow", bold); chunk.setGenericTag("http://pages.itextpdf.com/ebook-stackoverflow-questions.html"); Phrase p = new Phrase("Download "); p.add(chunk); p.add(" and discover more than 200 questions and answers."); canvas.saveState(); canvas.concatCTM(transform); ColumnText ct = new ColumnText(canvas); ct.setSimpleColumn(300, 0, 800, 400); ct.addText(p); ct.go(); canvas.restoreState(); stamper.close(); reader.close(); }
public void manipulatePdf(String src, String dest) throws IOException, DocumentException { PdfReader reader = new PdfReader(src); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest)); AffineTransform transform = AffineTransform.getRotateInstance(Math.PI / 2); stamper.getWriter().setPageEvent(new AddAnnotation(stamper, transform)); PdfContentByte canvas = stamper.getOverContent(1); Font bold = new Font(FontFamily.HELVETICA, 12, Font.BOLD); Chunk chunk = new Chunk("The Best iText Questions on StackOverflow", bold); chunk.setGenericTag("http://pages.itextpdf.com/ebook-stackoverflow-questions.html"); Phrase p = new Phrase("Download "); p.add(chunk); p.add(" and discover more than 200 questions and answers."); canvas.saveState(); canvas.concatCTM(transform); ColumnText ct = new ColumnText(canvas); ct.setSimpleColumn(36, -559, 806, -36); ct.addText(p); ct.go(); canvas.restoreState(); stamper.close(); reader.close(); }
/** * Constructs a <CODE>PdfPCell</CODE> with an <CODE>Image</CODE>. The * default padding is 0.25 for a border width of 0.5. * * @param image the <CODE>Image</CODE> * @param fit <CODE>true</CODE> to fit the image to the cell */ public PdfPCell(Image image, boolean fit) { super(0, 0, 0, 0); borderWidth = 0.5f; border = BOX; column.setLeading(0, 1); if (fit) { this.image = image; setPadding(borderWidth / 2); } else { image.setScaleToFitLineWhenOverflow(false); column.addText(this.phrase = new Phrase(new Chunk(image, 0, 0, true))); setPadding(0); } }
/** * Constructs a <CODE>PdfPCell</CODE> with an <CODE>Image</CODE>. The * default padding is 0.25 for a border width of 0.5. * * @param image the <CODE>Image</CODE> * @param fit <CODE>true</CODE> to fit the image to the cell */ public PdfPCell(Image image, boolean fit) { super(0, 0, 0, 0); borderWidth = 0.5f; border = BOX; column.setLeading(0, 1); if (fit) { this.image = image; setPadding(borderWidth / 2); } else { image.setScaleToFitLineWhenOverflow(false); column.addText(this.phrase = new Phrase(new Chunk(image, 0, 0, true))); setPadding(0); } }
compositeColumn.setArabicOptions(arabicOptions); compositeColumn.setSpaceCharRatio(spaceCharRatio); compositeColumn.addText(para); if (!(firstPass && adjustFirstLine)) { yLine -= para.getSpacingBefore(); compositeColumn.setArabicOptions(arabicOptions); compositeColumn.setSpaceCharRatio(spaceCharRatio); compositeColumn.addText(item); if (!(firstPass && adjustFirstLine)) { yLine -= item.getSpacingBefore();
compositeColumn.setArabicOptions(arabicOptions); compositeColumn.setSpaceCharRatio(spaceCharRatio); compositeColumn.addText(para); if (!(firstPass && adjustFirstLine)) { yLine -= para.getSpacingBefore(); compositeColumn.setArabicOptions(arabicOptions); compositeColumn.setSpaceCharRatio(spaceCharRatio); compositeColumn.addText(item); if (!(firstPass && adjustFirstLine)) { yLine -= item.getSpacingBefore();