I'm using iText PDF 2.1.7 to create a PDF. Anyone has an idea if stretching the height of a single character (a closing curly brace, ASCII 125), is possible with iText PDF?
The height of the stretched curly brace will depend on the height of the preceding cell's height. (Pardon my sample image, the upper curly brace should be taller than the lower curly brace.
If stretching the height of a single character is not possible, any other workaround you could suggest that still utilizes iText PDF library?
Thanks much.
I'm now using the iText version 5.4.0.
I'm having problem with scaling the height of the Image. Also, the Image is on the wrong position, though I copied the Cell's position. The bottom part of the curly brace is not displayed.
Do you know what is wrong with the way I scale the Image and on how I position it? Thanks.
public void cellLayout(PdfPCell cell, Rectangle position,
PdfContentByte[] canvases) {
try {
BaseFont bf = BaseFont.createFont(
CreatePDFCurlyBrace.DEFAULT_ENGLISH_FONT_TTF, BaseFont.IDENTITY_H,
BaseFont.EMBEDDED);
String curlyBrace = "}";
float width = bf.getWidthPoint(curlyBrace, 12);
float height = bf.getAscentPoint(curlyBrace, 12)
- bf.getDescentPoint(curlyBrace, 12);
PdfTemplate template = this.cb.createTemplate(width, height);
template.beginText();
template.setFontAndSize(bf, 12);
template.setTextMatrix(0, bf.getDescentPoint(curlyBrace, 12));
template.showText(curlyBrace);
template.endText();
// Scale the image so that its height corresponds
// with the height of the cell
Image img = Image.getInstance(template);
img.scaleToFit(1000f, position.getHeight());
img.setAbsolutePosition(position.getRight(), position.getBottom());
cb.addImage(img);
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}