I solved image alignment aswell. I used the PdfContentByte for that aswell.
I thought I would share my function for anyone else who might be needing the same thing:
/// <summary>
/// Add spread to pdf
/// </summary>
///
a hidden field containing ids for
///
the contentbyte object grabbed from the writer
///
a textbox containing some text we want to write above our picture
///
the font we want to use
///
is this the pic in the top, second or third row? (0, 1, 2)
private void AddSpreadsToPDF(HiddenField i_hf, PdfContentByte i_cb, TextBox i_textbox, BaseFont i_font, int i_nr)
{
// skriv ut texten ovanför
i_cb.BeginText();
i_cb.SetFontAndSize(i_font, 10);
i_cb.SetColorFill(Color.BLACK);
//i_cb.SetTextMatrix(85, 580 - (i_nr*220));
//i_cb.ShowText(i_textbox.Text);
i_cb.SetTextMatrix(83, 710 - (i_nr*230));
i_cb.ShowText(i_textbox.Text);
i_cb.EndText();
string[] splitVals = i_hf.Value.Split(',');
int cnt = 0;
foreach (string val in splitVals)
{
if (val == "")
continue;
if (Request.Form[i_hf.ClientID.Substring(6) + val] != "")
{
iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(Server.MapPath(Request.Form[i_hf.ClientID + val]));
img.SetAbsolutePosition(83 + (cnt*246), 510 - (i_nr*230));
img.ScaleAbsolute(190, 190);
i_cb.AddImage(img);
cnt++;
}
}
}
Ofcourse this code will have to be modified to work for your own need. But you guys hopefully get the picture.