Hi guys I have an instance where I have a logo image as part of some
artwork..

If a user uploads a new logo I have a form field which is larger than the
default logo.

I then use that form field to position the new image.

The problem is I need to set the background colour of that form field to
white so that it covers the old logo in the event that the new image is
smaller than the old logo..

what I have done is:

    foreach (var imageField in imageReplacements)
                                {
                                        fields.SetFieldProperty(imageField.Key, 
"bgcolor",
iTextSharp.text.Color.WHITE, null);
                                        fields.RegenerateField(imageField.Key);

                                        PdfContentByte overContent =
stamper.GetOverContent(imageField.Value.PageNumber);
                                        float[] logoArea = 
fields.GetFieldPositions(imageField.Key);
                                        if (logoArea != null)
                                        {
                                                iTextSharp.text.Rectangle 
logoRect = new
iTextSharp.text.Rectangle(logoArea[1], logoArea[2], logoArea[3],
logoArea[4]);

                                                var logo =
iTextSharp.text.Image.GetInstance(imageField.Value.Location);
                                                if (logo.Width >= 
logoRect.Width || logo.Height >= logoRect.Height)
                                                {
                                                        
logo.ScaleToFit(logoRect.Width, logoRect.Height);
                                                }
                                                logo.Alignment = 
iTextSharp.text.Image.ALIGN_LEFT;
                                                
logo.SetAbsolutePosition(logoRect.Left, logoArea[2] + (logoRect.Height
- logo.ScaledHeight) / 2);
                                                // left:  logoArea[3] - 
logo.ScaledWidth + (logoRect.Width -
logo.ScaledWidth) / 2

                                                overContent.AddImage(logo);
                                        }
                                }

The problem with this is that the background colour of the field is set to
white and the image then doesn't appear.. i remove the SetFieldProperty and
RegenerateField commands and the image replacement works fine..

is there a way to set a stacking order on layers?

--
View this message in context: 
http://itext-general.2136553.n4.nabble.com/Use-Field-to-set-Image-Position-and-set-that-field-background-color-to-white-tp3380453p3380453.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to