List of usage examples for com.lowagie.text.pdf PdfTemplate showTextAligned
public void showTextAligned(int alignment, String text, float x, float y, float rotation)
From source file:questions.images.CustomizedTitleBar.java
public static Image getTitleBar(PdfWriter writer, Image background, String title) throws DocumentException, IOException { float width = background.getWidth(); float height = background.getHeight(); PdfTemplate tmp = writer.getDirectContent().createTemplate(width, height); tmp.addImage(background, width, 0, 0, height, 0, 0); BaseFont font = BaseFont.createFont(); tmp.beginText();/*from w w w . j a v a 2s .c o m*/ tmp.setGrayFill(1); tmp.setFontAndSize(font, 18); tmp.showTextAligned(Element.ALIGN_CENTER, title, width / 2, 4, 0); tmp.endText(); return Image.getInstance(tmp); }