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?