PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Jul 12, 2024 3:00 pm

All times are UTC

Forum rules

Please read this before posting on this forum: Forum Rules

Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Sun Jan 15, 2023 6:40 pm 

Joined: Fri Jan 13, 2023 3:42 pm
Posts: 1
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.

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.

// Save the document...

I have attached two sample file here: https://we.tl/t-8d3GE55SxE

Can anyone help me ?

Thanks and Best Regards

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: Google [Bot] and 39 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group