PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 2:52 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Text annotation contents
PostPosted: Thu Apr 12, 2018 4:36 pm 
Offline

Joined: Thu Apr 12, 2018 4:25 pm
Posts: 2
I am using PDFSharp to replace some placeholder text in a template PDF with some values I gather from a user.

The text I replace is all within text annotation objects, however I am finding that if I update the "contents" it does not actually update the displayed text. If I delete the /AP key it works in Bluebeam but not for Adobe.

Code:
foreach (PdfSharp.Pdf.Annotations.PdfAnnotation anno in tempPDF.Pages[0].Annotations)
            {
                foreach (var wordToReplace in replacements)
                {
                    anno.Contents = anno.Contents.Replace(wordToReplace.Key, wordToReplace.Value);
                }
                anno.Elements.Remove("/AP");
            }


Can anyone shed any light on how I can resolve this? I've read that PDF's have multiple internal dictionaries that control text display - is there a way I can manipulate these to solve my issues?


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 25, 2018 8:29 am 
Offline

Joined: Thu Apr 12, 2018 4:25 pm
Posts: 2
I've uploaded an example input file below, and the code output, to illustrate the issue.

WeTransfer download link:
https://we.tl/z9VdruVRNX


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 126 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