Hi I am trying to create an Invoice where the company logo and the address are displayed next to each other. The company logo is displayed on the left and the text beneath i
In my case, I was working in existing functionality and had to do so with in a cell. So here is what I did
public PdfPCell buildDesiredCell() throws Exception {
PdfPCell cell = new PdfPCell();
PdfPTable headerTable = new PdfPTable(2);
headerTable.setWidthPercentage(100f);
PdfPCell leftCell = new PdfPCell();
String imagePath;
imagePath = D:\....;//specify any path
Image img = Image.getInstance(imagePath);
img.scaleAbsoluteHeight(120f);
img.scaleAbsoluteWidth(120f);
img.setAlignment(Element.ALIGN_LEFT);
leftCell.addElement(img);
leftCell.setBorder(Rectangle.NO_BORDER);
headerTable.addCell(leftCell);
PdfPCell rightCell = new PdfPCell();
Paragraph addText= new Paragraph(" This is required text", smallStandardFont);
rightCell .addElement(addText);
rightCell .setBorder(Rectangle.NO_BORDER);
rightCell .setPaddingLeft(5);
headerTable.addCell(rightCell);
cell.setBorder(Rectangle.NO_BORDER);
cell.addElement(headerTable);
return cell;
}