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

  • Home
  • SEARCH
  • 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 6351665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:03:00+00:00 2026-05-24T22:03:00+00:00

I have to insert a an image in a pdf. That is, wherever I

  • 0

I have to insert a an image in a pdf. That is, wherever I see a text ‘Signature’, I have to insert an signature image there . I can do by saying absolute positions .
But, I am looking for how to find the position of the word ‘Signature’ in the pdf and insert the image.

Appreciate ur help!

This is the working code:

 using (Stream inputImageStream = new FileStream(@"C:\signature.jpeg", FileMode.Open, FileAccess.Read, FileShare.Read))
    using (Stream outputPdfStream = new FileStream(@"C:\test\1282011\Result.pdf", FileMode.Create, FileAccess.Write, FileShare.None))
    {

        var reader = new PdfReader(@"C:\Test\1282011\Input.pdf");
        var stamper = new PdfStamper(reader, outputPdfStream);
        var count = reader.NumberOfPages;



        iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(inputImageStream);
        image.SetAbsolutePosition(300, 200); // Absolute position
        image.ScaleToFit(200, 30);

        PRTokeniser pkt = null;
        string strpages = string.Empty;
        System.Text.StringBuilder build = new System.Text.StringBuilder();


        for (int i = 1; i <= count; i++)
        {
            var pdfContentByte = stamper.GetOverContent(i);
            if (pdfContentByte != null)
            {
                pkt = new PRTokeniser(stamper.Reader.GetPageContent(i));
                while (pkt.NextToken())
                {
                    if (pkt.TokenType == PRTokeniser.TokType.STRING)
                    {
                        if (pkt.StringValue == "Signature")
                        {
                            pdfContentByte.AddImage(image);
                        }

                    }

                }
            }
        }
        stamper.Close();


    }
}

After some googling, I found out that I could absolute position of text as follows:

extSharp.text.pdf.AcroFields fields = stamper.AcroFields;
               IList<iTextSharp.text.pdf.AcroFields.FieldPosition> signatureArea = fields.GetFieldPositions("Signature");
                iTextSharp.text.Rectangle rect=  signatureArea.First().position;
                iTextSharp.text.Rectangle logoRect = new iTextSharp.text.Rectangle(rect);
                image.SetAbsolutePosition(logoRect.Width ,logoRect .Height );

But the variable , signatureArea is null all the time even when the pdf contains the word ‘Signature’.

Any input..? 🙂
Jaleel

  • 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-24T22:03:01+00:00Added an answer on May 24, 2026 at 10:03 pm

    Check out PdfTextExtractor and specifically the LocationTextExtractionStrategy. Create a class in your project with the exact code for the LocationTextExtractionStrategy and put a breakpoint on the line return sb.ToString(); (line 131 in SVN) and take a look at the contents of the variable locationalResult. You’ll see pretty much exactly what you’re looking for, a collection of text with start and end locations. If your search word isn’t on a line by itself you might have to dig a little deeper but this should point you in the right direction.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project that has to export images to PDF. Images and text
I have wrote a very simple php upload. But I want to insert image
I am attempting to insert an image into a rich text file. I have
I have a force-download script that produces good results with PDF and plain text,
I have a UIButton in which I want to insert an image that would
I have an existing PDF and I can use FdFWriter to input to text
I have written code to insert an Image in SQL server but it throws
This is the code I have. I'm trying to insert a image to show
I have this: Create Proc CrearNuevoImagen @imagen image AS INSERT INTO Imagenes(imagen) VALUES( @imagen
I have an INSERT query that is pulling data from two tables and inserting

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.