Code snippet follows. Error happens on line “pdfDocument.Pages.Accept(textFragmentAbsorber);”
We’re using a newly purchased version of the Aspose.Pdf.DLL (v23.1.1.0)
Document causing issue attached Problem PDF.pdf (927.3 KB)
using (Document pdfDocument = new Document(@"C:\Users\paul.jones\Downloads\Problem PDF.pdf"))
{
//create TextAbsorber object to find all instances of the input search phrase
//using regex ({[^}]*}) ---- (#[^#]*#) -- #SPG#
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("(#[^#]*@#)");
TextSearchOptions textSearchOptions = new TextSearchOptions(true);
textFragmentAbsorber.TextSearchOptions = textSearchOptions;
//accept the absorber for all the pages
pdfDocument.Pages.Accept(textFragmentAbsorber);
//get the extracted text fragments
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
//loop through the fragments
foreach (TextFragment textFragment in textFragmentCollection)
{
//update text and other properties
textFragment.Text = "1";
textFragment.TextState.Font = FontRepository.FindFont("Arial");
textFragment.TextState.FontSize = 12;
}
}