We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Replace text that in TextBoxField is failed with aspose.pdf

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

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));
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
foreach (TextFragment textFragment in textFragmentCollection)
textFragment.Text = targetText;

the demo file:
demo.pdf (21.7 KB)

Please tell me how to replace text that in TextBoxField.Thank you!


The text box in the shared PDF is actually an annotation. The annotations and form fields are different from the textual content on a page. You need to process/modify it using PDF Annotations.