New line characters in PDF in C# using Aspose.PDF for .NET - System.NullReferenceException

When trying to identify the text fragments enclosed in square brackets and replace the [] with empty string, we are getting the below null reference exception if the text fragment contains \r\n or \n or nbsp characters.

Error-System.NullReferenceException: Object reference not set to an instance of an object.
at #=ztxquhYRowjnsZQxP8GiFPpTJwpx3QJg93V2QFsDU09CBI92XJxVn4ao=.#=zW_Vfbi8Nj3PByiegGg==(#=zdfPIt15GsqAtGWNwksq3JS0= #=zUw0fpKg=, String #=zPMPoiS0=, Int32 #=zxOqyBoQ=, Int32 #=zJHlnqi8=)
at #=ztxquhYRowjnsZQxP8GiFPpTJwpx3QJg93V2QFsDU09CBI92XJxVn4ao=.#=zW_Vfbi8Nj3PByiegGg==(#=zdfPIt15GsqAtGWNwksq3JS0= #=zUw0fpKg=, String #=zPMPoiS0=)
at #=ztxquhYRowjnsZQxP8GiFPpTJwpx3QJg93V2QFsDU09CBI92XJxVn4ao=.#=zISNiZ5j016Ue3U4lnq2kWet9EkvS(String #=zPMPoiS0=, Font #=zUw0fpKg=, Font& #=z$B71qFUm5SM2EGdhq6POH1s=)
at #=z$66iMVMGcSZZ6hCn5zcs8teks$4yDhsZhA==.#=z5FM23$lxFBDDOsRNCA==(Double #=z7pPY6dFIxvI$, TextState #=zMeUYjhU=, String& #=zQ6fxqec=)
at Aspose.Pdf.Text.TextFragment.#=z6z_Y4Sm0lzuS(String #=zQIf$T38=)
at Aspose.Pdf.Text.TextFragment.set_Text(String value)

Attached the PDF pdf-cbcf3cda72e341d8a43cd9c58539f74a.pdf (57.3 KB)
In cell A7, getting error when trying to remove square brackets [].

Below is the code for your reference
var doc = new Aspose.Pdf.Document(path);

var searchTerm = “\[(?s)(.*?)\]”;
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(searchTerm);
TextSearchOptions textSearchOptions = new TextSearchOptions(true);
textFragmentAbsorber.TextSearchOptions = textSearchOptions;

doc.Pages.Accept(textFragmentAbsorber);

TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
foreach (var textFragment in textFragmentCollection)
{
textFragment.Text = textFragment.Text.Replace("[", “”).Replace("]", “”);
textFragment.TextState.ForegroundColor = Color.Black;
textFragment.TextState.BackgroundColor = Color.Gray;
}

@susmithaputhana

Can you please share which API version are you using at your end?

@asad.ali Aspose PDF 23.9

@susmithaputhana

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-55637

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Can you please provide an update on this.

@susmithaputhana

The ticket was recently logged in our issue tracking system and it is pending for investigation. We are afraid that no updates are available at the moment. We will surely investigate and resolve the ticket on a first come first serve basis and let you know once some progress is made towards its resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.

Any update on this issue ?

@susmithaputhana

Sadly, there are no updates to share at the moment as the issue was not investigated. We will inform you within this forum thread once we have some news about ticket resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.

Can you please provide an update on this. This is a blocker for us

@susmithaputhana

We are afraid that we are not in a position to share some reliable ETA because investigation of the ticket is not yet completed. Your concerns have been recorded and as soon as we make some progress towards ticket resolution, we will update you via this forum thread. Please spare us some time.

We apologize for your inconvenience.