Env
- Windows 11
- Aspose.PDF for .NET 24.1
Code
void Test()
{
var doc = new Aspose.Pdf.Document(@"C:\Users\Administrator\Desktop\test\test.pdf");
var textFragmentAbsorber = new TextFragmentAbsorber("XXXX");
doc.Pages.Accept(textFragmentAbsorber);
var textFragmentCollection = textFragmentAbsorber.TextFragments;
foreach (var textFragment in textFragmentCollection)
{
//If add this line, it's OK.
//textFragment.TextState.Font = Aspose.Pdf.Text.FontRepository.FindFont("Arial");
textFragment.Text = "ABCDEFG";
textFragment.TextState.Font.Dump();
Aspose.Pdf.Text.FontRepository.FindFont("SimSun").Dump();
}
doc.Save(@"C:\Users\Administrator\Desktop\test\out.pdf");
}
Files
image.png (92.0 KB)
before.png (58.6 KB)
after.png (62.2 KB)
test.zip (392.9 KB)