I have a pdf document,I want to replace some text by aspose.pdf,but some text can’t be replace that in TextBoxField.
the version is Aspose.PDF for .Net 21.6.0.0.
the sample code :
var doc = new Aspose.Pdf.Document(@“D:\abc\1212\demo.pdf”);
var sourceText = “text”;
var targetText = “xxx”;
Regex ruleRegexp = new Regex(Regex.Escape(sourceText));
var textFragmentAbsorber = new TextFragmentAbsorber(ruleRegexp, new TextSearchOptions(true));
doc.Pages.Accept(textFragmentAbsorber);
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
foreach (TextFragment textFragment in textFragmentCollection)
{
textFragment.Text = targetText;
}
doc.Save(@“D:\abc\1212\demo1.pdf”);
the demo file:
demo.pdf (21.7 KB)
Please tell me how to replace text that in TextBoxField.Thank you!