List of usage examples for com.itextpdf.text Chunk setTextRenderMode
public Chunk setTextRenderMode(final int mode, final float strokeWidth, final BaseColor strokeColor)
From source file:watermark.java
public static void main(String[] args) { try {//from w w w .j a v a 2s .c om PdfReader reader = new PdfReader(args[0]); PdfStamper stamp = new PdfStamper(reader, new FileOutputStream(args[1])); stamp.getWriter().setCompressionLevel(9); // without this code it'll 3 times bigger int bottom_margin = Integer.parseInt(args[2]); String lic = String.format(LIC, args[3]); BaseFont bf = BaseFont.createFont(FONTFILE, BaseFont.IDENTITY_H, BaseFont.EMBEDDED); Chunk c = new Chunk(lic, new Font(bf, 7, Font.NORMAL, TCOLOR)); c.setTextRenderMode(PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE, 1 / 800f, null); Phrase phrase = new Phrase(c); int pages = reader.getNumberOfPages(); int xpos = 90; for (int i = 1; i <= pages; i++) { if (i % 2 == 0) xpos = 160; else xpos = 90; PdfContentByte under = stamp.getUnderContent(i); ColumnText.showTextAligned(under, Element.ALIGN_LEFT, phrase, xpos, bottom_margin, -0); } stamp.setFullCompression(); // without this code it'll 3 times bigger stamp.close(); } catch (Exception e) { e.printStackTrace(); } }