I'm trying to put text at specified locations in pdf and using code
public static PdfContentByte setContentSize(com.itextpdf.text.Document itextDocument) {
itextDocument.open();
PdfContentByte contentByte = getPdfWriter(itextDocument).getDirectContent();
contentByte.saveState();
Font font = new Font(FontFamily.TIMES_ROMAN, 12);
BaseFont baseFont = font.getCalculatedBaseFont(false);
contentByte.beginText();
contentByte.setFontAndSize(baseFont, 12);
contentByte.setTextMatrix(50, 800);
return contentByte;
}
ColumnText ct = new ColumnText(contentByte);
ct.setSimpleColumn(new Phrase(new Chunk(text, FontFactory.getFont(FontFactory.HELVETICA, 18, Font.NORMAL))),
46, 190, 530, 36, 25, com.itextpdf.text.Element.ALIGN_LEFT);
ct.go();
//contentByte.showTextAligned(PdfContentByte.ALIGN_LEFT, text, 150, 240, 0);
//Phrase phrase = new Phrase(text, new Font());
//ColumnText.showTextAligned(contentByte, com.itextpdf.text.Element.ALIGN_LEFT, phrase, 200, 572, 0);
I have tried commented code also but the text is not printing in pdf. Any suggestion will be appreciated.