}
img.setAbsolutePosition(left, tly - img.getScaledHeight());
try {
canvases[PdfPTable.TEXTCANVAS].addImage(img);
} catch (DocumentException e) {
throw new ExceptionConverter(e);
}
} else {
// rotation sponsored by Connection GmbH
if (cell.getRotation() == 90 || cell.getRotation() == 270) {
float netWidth = maxHeight - cell.getEffectivePaddingTop() - cell.getEffectivePaddingBottom();
float netHeight = cell.getWidth() - cell.getEffectivePaddingLeft() - cell.getEffectivePaddingRight();
ColumnText ct = ColumnText.duplicate(cell.getColumn());
ct.setCanvases(canvases);
ct.setSimpleColumn(0, 0, netWidth + 0.001f, -netHeight);
try {
ct.go(true);
} catch (DocumentException e) {
throw new ExceptionConverter(e);
}
float calcHeight = -ct.getYLine();
if (netWidth <= 0 || netHeight <= 0)
calcHeight = 0;
if (calcHeight > 0) {
if (cell.isUseDescender())
calcHeight -= ct.getDescender();
ct = ColumnText.duplicate(cell.getColumn());
ct.setCanvases(canvases);
ct.setSimpleColumn(0, -0.001f, netWidth + 0.001f, calcHeight);
float pivotX;
float pivotY;
if (cell.getRotation() == 90) {
pivotY = cell.getTop() + yPos - maxHeight + cell.getEffectivePaddingBottom();
switch (cell.getVerticalAlignment()) {
case Element.ALIGN_BOTTOM:
pivotX = cell.getLeft() + xPos + cell.getWidth() - cell.getEffectivePaddingRight();
break;
case Element.ALIGN_MIDDLE:
pivotX = cell.getLeft() + xPos + (cell.getWidth() + cell.getEffectivePaddingLeft() - cell.getEffectivePaddingRight() + calcHeight) / 2;
break;
default: //top
pivotX = cell.getLeft() + xPos + cell.getEffectivePaddingLeft() + calcHeight;
break;
}
saveAndRotateCanvases(canvases, 0,1,-1,0,pivotX,pivotY);
}
else {
pivotY = cell.getTop() + yPos - cell.getEffectivePaddingTop();
switch (cell.getVerticalAlignment()) {
case Element.ALIGN_BOTTOM:
pivotX = cell.getLeft() + xPos + cell.getEffectivePaddingLeft();
break;
case Element.ALIGN_MIDDLE:
pivotX = cell.getLeft() + xPos + (cell.getWidth() + cell.getEffectivePaddingLeft() - cell.getEffectivePaddingRight() - calcHeight) / 2;
break;
default: //top
pivotX = cell.getLeft() + xPos + cell.getWidth() - cell.getEffectivePaddingRight() - calcHeight;
break;
}
saveAndRotateCanvases(canvases, 0,-1,1,0,pivotX,pivotY);
}
try {
ct.go();
} catch (DocumentException e) {
throw new ExceptionConverter(e);
} finally {
restoreCanvases(canvases);
}
}
}
else {
float fixedHeight = cell.getFixedHeight();
float rightLimit = cell.getRight() + xPos
- cell.getEffectivePaddingRight();
float leftLimit = cell.getLeft() + xPos
+ cell.getEffectivePaddingLeft();
if (cell.isNoWrap()) {
switch (cell.getHorizontalAlignment()) {
case Element.ALIGN_CENTER:
rightLimit += 10000;
leftLimit -= 10000;
break;
case Element.ALIGN_RIGHT:
if (cell.getRotation() == 180) {
rightLimit += 20000;
}
else {
leftLimit -= 20000;
}
break;
default:
if (cell.getRotation() == 180) {
leftLimit -= 20000;
}
else {
rightLimit += 20000;
}
break;
}
}
ColumnText ct = ColumnText.duplicate(cell.getColumn());
ct.setCanvases(canvases);
float bry = tly
- (maxHeight /* cell.height() */
- cell.getEffectivePaddingTop() - cell.getEffectivePaddingBottom());
if (fixedHeight > 0) {
if (cell.getHeight() > maxHeight) {
tly = cell.getTop() + yPos - cell.getEffectivePaddingTop();
bry = cell.getTop() + yPos - maxHeight + cell.getEffectivePaddingBottom();
}
}
if ((tly > bry || ct.zeroHeightElement()) && leftLimit < rightLimit) {
ct.setSimpleColumn(leftLimit, bry - 0.001f, rightLimit, tly);
if (cell.getRotation() == 180) {
float shx = leftLimit + rightLimit;
float shy = yPos + yPos - maxHeight + cell.getEffectivePaddingBottom() - cell.getEffectivePaddingTop();
saveAndRotateCanvases(canvases, -1,0,0,-1,shx,shy);
}
try {
ct.go();
} catch (DocumentException e) {
throw new ExceptionConverter(e);
} finally {
if (cell.getRotation() == 180) {
restoreCanvases(canvases);
}
}