List of usage examples for com.itextpdf.text.pdf ColumnText setLeading
public void setLeading(final float fixedLeading, final float multipliedLeading)
From source file:mkl.testarea.itext5.pdfcleanup.StrictPdfCleanUpProcessor.java
License:Open Source License
private void drawOverlayText(PdfContentByte canvas, List<Rectangle> textRectangles, PdfString overlayText, PdfString otDA, PdfNumber otQ, PdfBoolean otRepeat) throws DocumentException, IOException { ColumnText ct = new ColumnText(canvas); ct.setLeading(0, 1.2F); ct.setUseAscender(true);// ww w.ja va2 s . c om String otStr = overlayText.toUnicodeString(); canvas.saveState(); Map<String, List> parsedDA = parseDAParam(otDA); Font font = null; if (parsedDA.containsKey(STROKE_COLOR)) { List strokeColorArgs = parsedDA.get(STROKE_COLOR); setStrokeColor(canvas, strokeColorArgs); } if (parsedDA.containsKey(FILL_COLOR)) { List fillColorArgs = parsedDA.get(FILL_COLOR); setFillColor(canvas, fillColorArgs); } if (parsedDA.containsKey("Tf")) { List tfArgs = parsedDA.get("Tf"); font = retrieveFontFromAcroForm((PdfName) tfArgs.get(0), (PdfNumber) tfArgs.get(1)); } for (Rectangle textRect : textRectangles) { ct.setSimpleColumn(textRect); if (otQ != null) { ct.setAlignment(otQ.intValue()); } Phrase otPhrase; if (font != null) { otPhrase = new Phrase(otStr, font); } else { otPhrase = new Phrase(otStr); } float y = ct.getYLine(); if (otRepeat != null && otRepeat.booleanValue()) { int status = ct.go(true); while (!ColumnText.hasMoreText(status)) { otPhrase.add(otStr); ct.setText(otPhrase); ct.setYLine(y); status = ct.go(true); } } ct.setText(otPhrase); ct.setYLine(y); ct.go(); } canvas.restoreState(); }