Hi everyone,
I am trying to replace a FreeText Annotation Contents, but I am facing two issue:
1. The annotation "Contents" is modified only at page #1. Page #2 and Page #3 Annotations are not modified
2. Even if the "Contents" is changed, on the PDF I can still see the old text in the Annotation Rectangle.
This is the code I am using, but still can't get what I am doing wrong.
Code:
string strInputFile = @"F:\DEV\TEST\Input.pdf";
string strOutputFile = @"F:\DEV\TEST\Output.pdf";
// Open the output document
PdfDocument outputDocument = new PdfDocument();
PdfDocument inputDocument = PdfReader.Open(strInputFile, PdfDocumentOpenMode.Import);
// Iterate pages
int count = inputDocument.PageCount;
for (int idx = 0; idx < count; idx++)
{
// Get the page from the external document...
PdfPage page = inputDocument.Pages[idx];
for (int a = 0; a < page.Annotations.Count; a++)
{
PdfAnnotation annotation = page.Annotations[a];
annotation.Contents = "NewValue";
}
// ...and add it to the output document.
outputDocument.AddPage(page);
}
// Save the document...
outputDocument.Save(strOutputFile);
I have attached two sample file here:
https://we.tl/t-8d3GE55SxECan anyone help me ?
Thanks and Best Regards