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

Free Support Forum - aspose.com

"Invalid Font Name" TextFragmentAbsorber Document.Pages.Accept command

I’ve seen this reported elsewhere on the forum but it wasn’t resolved on there.

Details follow in my next comment.

I’ve read that ASPOSE only works with a limited number of fonts but can you let me know if this means we can’t resolve the problem? We have no control over the PDF formats users can upload to our site so this could happen any time.

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;
    }
}

@pjjonah66,

I was able to reproduce the error with the newest version 23.2.

I will be creating a bug report.

@pjjonah66
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-53746

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.