Unable to edit / Annotation content

I am trying to change the text in some PDF annotations using iTextSharp. Here is my code:

    void changeAnnotations(string inputPath, string outputPath)
    {
        PdfReader pdfReader = new PdfReader(inputPath);
        PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(outputPath, FileMode.Create));

        //get the PdfDictionary of the 1st page
        PdfDictionary pageDict = pdfReader.GetPageN(1);

        //get annotation array
        PdfArray annotArray = pageDict.GetAsArray(PdfName.ANNOTS);

        //iterate through annotation array
        int size = annotArray.Size;
        for (int i = 0; i < size; i++)
        {

            //get value of /Contents
            PdfDictionary dict = annotArray.GetAsDict(i);
            PdfString contents = dict.GetAsString(PdfName.CONTENTS);

            //check if /Contents key exists
            if (contents != null)
            {

                //set new value
                dict.Put(PdfName.CONTENTS, new PdfString("value has been changed"));
            }
        }
        pdfStamper.Close();
    }

When I open the output file in Adobe Reader, none of the texts change in any of the annotations. How to set new value in annotation?

UPDATE: I found that the value changes in the popup that appears when I click on the annotation. And in some cases, when I change this value in a popup, this change is then applied to the annotation.

0
source share
1 answer

As the OP explained in the comment:

This annotation is FreeTexthow can I find and change the text displayed in this text box?

:

  • , N AP
  • , RC DS,
  • , , DA ,

( . PDF ISO 32000-1 12.5.6.6 )

, , , ; , .

, , . /AP? , 28 0 R.

, . , 28 0 R, , N, . 28 0 R 28 0.

, , AP.

+1

All Articles