PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Text annotation contents
https://forum.pdfsharp.net/viewtopic.php?f=2&t=3763
Page 1 of 1

Author:  HGroves [ Thu Apr 12, 2018 4:36 pm ]
Post subject:  Text annotation contents

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?

Author:  HGroves [ Wed Apr 25, 2018 8:29 am ]
Post subject:  Re: Text annotation contents

I've uploaded an example input file below, and the code output, to illustrate the issue.

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

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/