private float AddImage(Image i, float left, float right, float extraHeight, int alignment) {
Image image = Image.GetInstance(i);
if (image.ScaledWidth > right - left) {
image.ScaleToFit(right - left, float.MaxValue);
}
FlushCurrentLine();
if (line == null) {
line = new PdfLine(left, right, alignment, leading);
}
PdfLine imageLine = line;
// left and right in chunk is relative to the start of the line
right = right - left;
left = 0f;
if ((image.Alignment & Image.RIGHT_ALIGN) == Image.RIGHT_ALIGN) { // fix Uwe Zimmerman
left = right - image.ScaledWidth;
} else if ((image.Alignment & Image.MIDDLE_ALIGN) == Image.MIDDLE_ALIGN) {
left = left + ((right - left - image.ScaledWidth) / 2f);
}
Chunk imageChunk = new Chunk(image, left, 0);
imageLine.Add(new PdfChunk(imageChunk, null));
AddLine(imageLine);
return imageLine.Height;
}