Hi,

I try to generate PDF document using PDF Form to bind data from database:

1) Get PdfStamper for the PDF Form
2) Get AcroFields from the PDFStamper
3) Bind each AcroField with data from database

Those steps works fine for normal Text fields. But I need add different
image/barcode on different pages as well. If I use PdfContentByte by using
stamp.GetOverContent(1), the image/barcode can only be shown on the first
page. My code is like below:

           // Get content to make changes
           PdfContentByte overContent = stamp.GetOverContent(1);

           // Try to add different image to ten different pages
           // Each Text field (to show image) is named PartnerLogo_1,
PartnerLogo_2, ...
           // The size of image is scaled to fit the size of Text field
           for (int i = 1; i <= 10; i++)
           {
               // Get logo image
               iTextSharp.text.Image logo =
iTextSharp.text.Image.GetInstance(Server.MapPath("~/PDFTemplate/logo" + i +
".jpg"));
               // Get the Text field to hold image
               float[] logoArea = fields.GetFieldPositions("PartnerLogo_" +
i);
               iTextSharp.text.Rectangle logoRect = new
Rectangle(logoArea[1], logoArea[2], logoArea[3], logoArea[4]);
               // right alignment
               logo.ScaleToFit(logoRect.Width, logoRect.Height);
               logo.SetAbsolutePosition(logoArea[3] - logo.ScaledWidth + (
logoRect.Width - logo.ScaledWidth) / 2,
                       logoArea[2] + (logoRect.Height - logo.ScaledHeight)
/ 2);
               overContent.AddImage(logo);
           }

Is there a way to get Text field position on different pages and add image
to the Text field?

Thanks a lot in advance!
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to