Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4076352
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:24:50+00:00 2026-05-20T17:24:50+00:00

Hi guys I have an instance where I have a logo image as part

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T17:24:51+00:00Added an answer on May 20, 2026 at 5:24 pm

    Annotations (such as form fields) are always on top of page contents. Annotation Z order is just the order of the annotations array on a given page.

    Page content Z order is just the order everything appears in the content stream. New drawing operators go on top of proceeding operators.

    If you want to cover your old image, draw a white box over it and then draw the new logo over top that. No need to worry about annotations.


    Actually, all you really need to do is not set the background color of the imageField. You’re already scaling the new logo to match the size of the old one.

    However, if you really must draw that white box, it’s fairly simple:

    overContent.setColorFill(iTextSharp.text.Color.WHITE);
    overContent.rectangle( logoRect );
    overcontent.fill();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

guys i have arrays in which i have to match this kind of text
Ok guys I basically have a class which takes in 3 strings through the
I have an app which got 4 TableViewController which each make an instance of
I have setup a new EC2 instance on AWS and I'm trying to get
Hey guys. I have a method that gets called each second which I want
Hey guys so I'm trying to construct some json based on a form submission.
I have a sharepoint list which has some Lookup fields. When I iterate through
Hello guys I have a function inside a utility class which returns the current
do you guys have any idea how to edit the the labels in the
Thus far you guys have been wildly helpful with me getting this little ditty

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.