I'm using iTextSharpText to build a PDF.
I was asked to add some dynamic text over an image. I've already tried some examples that I found on this forum and other websites, but I can't seem to get this right, and it's really driving me nuts.
I followed this thread (iTextSharp Adding Text plus Barcode in a single cell?), and tried both answers.
First I tried:
var img_operacao = Image.GetInstance(String.Format("{0}{1}", Settings.Default.SiteRootURL, "/PublishingImages/PDF_operacao.png"));
img_operacao.ScaleToFit(150, 41);
img_operacao.Alignment = Image.UNDERLYING;
var ph0 = new Phrase(title0, pageHeader);
var cell = new PdfPCell();
cell.AddElement(ph0);
cell.AddElement(new Phrase(new Chunk(img_operacao, 0, 0)));
table.AddCell(cell);
And I got this: http://imageshack.us/photo/my-images/515/25265113.png/
My second attempt:
var img_operacao = Image.GetInstance(String.Format("{0}{1}", Settings.Default.SiteRootURL, "/PublishingImages/PDF_operacao.png"));
img_operacao.ScaleToFit(150, 41);
img_operacao.Alignment = Image.UNDERLYING;
var cell = new PdfPCell
{
Border = Rectangle.NO_BORDER,
PaddingTop = 0,
PaddingBottom = 0,
HorizontalAlignment = Element.ALIGN_CENTER,
VerticalAlignment = Element.ALIGN_MIDDLE
};
var ph0 = new Phrase();
ph0.Add(new Chunk(title0, pageHeader));
ph0.Add(new Chunk(img_operacao, 0, 0, true));
cell.AddElement(ph0);
table.AddCell(cell);
And I got: http://imageshack.us/photo/my-images/688/89424619.png/
I've tried several other variations with chunks, paragraphs, etc, but I can't get the text over the image!!!
If there is someone that can help me, I would really appreciate it. I'm stuck right now...
Thanks a lot
Paula