I'm searching for a way to replace the text in a pdf in C#. The use case is we have a client that needs to sign a pdf and we want to pre populate a few of the fields before they download it. Things like date, name, title, etc. I've found a few potential options like PDFSharp however I can't seem to find a way to search based on text.
Resources I've found so far are:
Find a word in PDF using PDFSharp .
https://forum.pdfsharp.net/viewtopic.php?p=4010
However I wasn't able to get them working for my use case. Any help would be greatly appreciated.
UPDATE Here is the boiler plate code that I've been working with to try to do the search and replace:
String toFind = 'client-title';
String toReplace = 'John Doe';
PdfSharp.Pdf.PdfDocument PDFDoc = PdfReader.Open("path/to/original/file.pdf", PdfDocumentOpenMode.Import);
PdfSharp.Pdf.PdfDocument PDFNewDoc = new PdfSharp.Pdf.PdfDocument();
for(int i = 0; i < PDFDoc.Pages.Count; i++)
{
// Find toFind string and replace with toReplace string
PDFNewDoc.AddPage(PDFDoc.Pages[i]);
}
PDFNewDoc.Save("path/to/new/file.pdf");