Hi,
I am trying to find and replace a text in PDF used the sample code as it is.
But the output file the old text is replaced by a blank text. I am using the free version now.
Please help.
Thank you
String input = @"SearchReplaceTemplate.pdf";
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(input);
PdfPageBase page = doc.Pages[0];
PdfTextFindCollection collection = page.FindText("Spire.PDF for .NET", TextFindParameter.IgnoreCase);
String newText = "Spire.PDF API";
PdfTextFind find = collection.Finds[0];
PdfBrush brush = new PdfSolidBrush(Color.DarkBlue);
PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial", 15f, FontStyle.Bold));
RectangleF rec = find.Bounds;
page.Canvas.DrawRectangle(PdfBrushes.White, rec);
page.Canvas.DrawString(newText, font, brush, rec);
String result = "ReplaceFirstSearchedText_out.pdf";
doc.SaveToFile(result);