ERROR:Incorrect input string passed for font PHENLF+TimesNewRoman

hi i am getting this next error when i try to use regular expression to replace email and phone number.

ERROR:Incorrect input string passed for font PHENLF+TimesNewRoman

code sample

 Dim pdfDocument As new Aspose.pdf.Document(fileFolder + fileName)
       '---=== Email replace ===--
     Dim absorber As TextFragmentAbsorber = New TextFragmentAbsorber("\B[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+\S", New TextSearchOptions(True))
       
       
    Try
      absorber.TextReplaceOptions = New TextReplaceOptions(TextReplaceOptions.ReplaceAdjustment.None)
      absorber.TextReplaceOptions.ReplaceScope = TextReplaceOptions.Scope.REPLACE_ALL
      pdfDocument.Pages.Accept(absorber)
      pdfDocument.Pages(1).Accept(absorber)
        ' absorber.TextFragments(1).Text = "*****@*****.com"
      For Each textfragment As TextFragment In absorber.TextFragments
        textfragment.Text = "*****@*****.com"
      Next
      
 
      
      ' ' ---=== phone replace ===--
      Dim absorber2 As TextFragmentAbsorber = New TextFragmentAbsorber("\B\d{2,3}[-]?\d{6,7}", New TextSearchOptions(True))
      absorber2.TextReplaceOptions = New TextReplaceOptions(TextReplaceOptions.ReplaceAdjustment.None)
      ' absorber2.TextReplaceOptions.ReplaceScope = TextReplaceOptions.Scope.REPLACE_FIRST
      ' pdfDocument.Pages.Accept(absorber2)
      pdfDocument.Pages(1).Accept(absorber2)
      ' absorber2.TextFragments(1).Text = "**-*******"
      For Each textfragment As TextFragment In absorber2.TextFragments
        textfragment.Text = "**-*******"
      Next
      
      ' ' '---=== phone 2 replace ===--
      Dim absorber4 As TextFragmentAbsorber = New TextFragmentAbsorber("[\[+]?[9][7][2]\W?\d{2,3}\W?\d{3}\W?\d{4}", New TextSearchOptions(True))
      absorber4.TextReplaceOptions = New TextReplaceOptions(TextReplaceOptions.ReplaceAdjustment.None)
      ' absorber4.TextReplaceOptions.ReplaceScope = TextReplaceOptions.Scope.REPLACE_FIRST
      ' pdfDocument.Pages.Accept(absorber4)
      pdfDocument.Pages(1).Accept(absorber4)
      ' absorber4.TextFragments(1).Text = "**-*******"
      For Each textfragment As TextFragment In absorber4.TextFragments
        textfragment.Text = "**-*******"
      Next
      
      ' '---=== phone 2 replace ===--
      Dim absorber6 As TextFragmentAbsorber = New TextFragmentAbsorber("\B\S+\d{6,7}", New TextSearchOptions(True))
      absorber6.TextReplaceOptions = New TextReplaceOptions(TextReplaceOptions.ReplaceAdjustment.None)
      ' absorber6.TextReplaceOptions.ReplaceScope = TextReplaceOptions.Scope.REPLACE_FIRST
      ' pdfDocument.Pages.Accept(absorber6)
      pdfDocument.Pages(1).Accept(absorber6)
      ' absorber6.TextFragments(1).Text = "**-*******"
      For Each textfragment As TextFragment In absorber6.TextFragments
        textfragment.Text = "******"
      Next
      
      ' ' '---=== id replace ===--
      Dim absorber3 As TextFragmentAbsorber = New TextFragmentAbsorber("\d{9}", New TextSearchOptions(True))
      absorber3.TextReplaceOptions = New TextReplaceOptions(TextReplaceOptions.ReplaceAdjustment.None)
      ' absorber3.TextReplaceOptions.ReplaceScope = TextReplaceOptions.Scope.REPLACE_FIRST
      ' pdfDocument.Pages.Accept(absorber3)
      pdfDocument.Pages(1).Accept(absorber3)
      ' absorber3.TextFragments(1).Text = "**-*******"
      For Each textfragment As TextFragment In absorber3.TextFragments
        textfragment.Text = "**-*******"
      Next
      
      ' '---=== id linkedIn ===--
      Dim absorber5 As TextFragmentAbsorber = New TextFragmentAbsorber("\B\S+(linkedin.com)\S{3,7}", New TextSearchOptions(True))
      ' absorber5.TextReplaceOptions = New TextReplaceOptions(TextReplaceOptions.ReplaceAdjustment.None)
      ' absorber5.TextReplaceOptions.ReplaceScope = TextReplaceOptions.Scope.REPLACE_FIRST
      ' pdfDocument.Pages.Accept(absorber5)
      pdfDocument.Pages(1).Accept(absorber5)
      ' absorber5.TextFragments(1).Text = "**-*******"
      For Each textfragment As TextFragment In absorber5.TextFragments
        textfragment.Text = "**-*******"
      Next
      Catch exp As Exception

	              '---=== response binary for debuging ===--
              '================================================================================================================
             Response.Clear()
              Response.ClearContent()
              Response.ClearHeaders()

              Response.TrySkipIisCustomErrors = true
              Response.StatusCode = 200
              Response.ContentType = "text/plain"
              Response.Write("ERROR:"&exp.Message)
             Response.end
              '================================================================================================================
                       
        End Try 

100015AllJobs_1534589_wety3av.pdf.pdf (83.3 KB)

@eranlipi

We tested the scenario in our environment while using Aspose.PDF for .NET 20.10 and following code snippet. We were unable to notice any exception.

[C#]

Document pdfDocument = new Document(dataDir + "100015AllJobs_1534589_wety3av.pdf.pdf");
foreach (Page page in pdfDocument.Pages)
{
 var textFragmentAbsorber = new TextFragmentAbsorber(@"\B[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+\S");
 var textSearchOptions = new TextSearchOptions(true);
 textFragmentAbsorber.TextSearchOptions = textSearchOptions;
 TextReplaceOptions textReplaceOptions = new TextReplaceOptions(TextReplaceOptions.Scope.REPLACE_ALL)
 {
  ReplaceAdjustmentAction = TextReplaceOptions.ReplaceAdjustment.None
 };
 textFragmentAbsorber.TextReplaceOptions = textReplaceOptions;
 page.Accept(textFragmentAbsorber);
 var textFragmentCollection = textFragmentAbsorber.TextFragments;
 foreach (TextFragment textFragment in textFragmentCollection)
 {
  textFragment.Text = "*****@*****.com";
 }

 textFragmentAbsorber = new TextFragmentAbsorber(@"\B\d{2,3}[-]?\d{6,7}");
 textFragmentAbsorber.TextSearchOptions = textSearchOptions;
 textFragmentAbsorber.TextReplaceOptions = textReplaceOptions;
 page.Accept(textFragmentAbsorber);
 textFragmentCollection = textFragmentAbsorber.TextFragments;
 foreach (TextFragment textFragment in textFragmentCollection)
 {
  textFragment.Text = "**-*******";
 }

 textFragmentAbsorber = new TextFragmentAbsorber(@"[\[+]?[9][7][2]\W?\d{2,3}\W?\d{3}\W?\d{4}");
 textFragmentAbsorber.TextSearchOptions = textSearchOptions;
 textFragmentAbsorber.TextReplaceOptions = textReplaceOptions;
 page.Accept(textFragmentAbsorber);
 textFragmentCollection = textFragmentAbsorber.TextFragments;
 foreach (TextFragment textFragment in textFragmentCollection)
 {
  textFragment.Text = "**-*******";
 }

 textFragmentAbsorber = new TextFragmentAbsorber(@"\B\S+\d{6,7}");
 textFragmentAbsorber.TextSearchOptions = textSearchOptions;
 textFragmentAbsorber.TextReplaceOptions = textReplaceOptions;
 page.Accept(textFragmentAbsorber);
 textFragmentCollection = textFragmentAbsorber.TextFragments;
 foreach (TextFragment textFragment in textFragmentCollection)
 {
  textFragment.Text = "**-*******";
 }

 textFragmentAbsorber = new TextFragmentAbsorber(@"\d{9}");
 textFragmentAbsorber.TextSearchOptions = textSearchOptions;
 textFragmentAbsorber.TextReplaceOptions = textReplaceOptions;
 page.Accept(textFragmentAbsorber);
 textFragmentCollection = textFragmentAbsorber.TextFragments;
 foreach (TextFragment textFragment in textFragmentCollection)
 {
  textFragment.Text = "******";
 }

 textFragmentAbsorber = new TextFragmentAbsorber(@"\B\S+(linkedin.com)\S{3,7}");
 textFragmentAbsorber.TextSearchOptions = textSearchOptions;
 textFragmentAbsorber.TextReplaceOptions = textReplaceOptions;
 page.Accept(textFragmentAbsorber);
 textFragmentCollection = textFragmentAbsorber.TextFragments;
 foreach (TextFragment textFragment in textFragmentCollection)
 {
  textFragment.Text = "**-*******";
 }
 page.Dispose();
}
pdfDocument.Save(dataDir + "test20.10.out.pdf");

test20.10.out.pdf (58.2 KB)

Would you kindly make sure to use latest version of the API and also, make sure to install all windows fonts in your system. In case you still face any issue, please let us know.