Getting "Invalid font name" exception when searching a document with RegEx

Hello,

I have code that is in production and has been working using Aspose.PDF to search for replaceable words and build an output pdf based on the source template read. One source document a customer used has an issue, where I call the Visit function of TextFragmentAbsorber, and Aspose.PDF throws a “Invalid font name” exception.

My questions are:

  1. Is there a list of unsupported fonts?
  2. Is there a list of supported font?

Thank You,

Michael W. Kelley

@mkelley

Thanks for contacting support.

Aspose.PDF supports 14 Microsoft Essential Core Fonts as well as others. There is no such limitation in supporting other fonts however, some specific fonts require license in order to work correctly. In such cases, we investigate the scenario and check the feasibility whether such support can be added to the API or not.

We request you to please share your sample PDF document along with minimal code snippet to reproduce the issue. We will test the scenario in our environment and address it accordingly.

I have a sample the customer provided and I have attached it to this bug, so that support may move forward with it.CPL_1-GPEPIP_010135473.pdf (80.4 KB)

@mkelley

Thanks for sharing sample document.

As requested earlier, would you kindly share minimal sample code snippet that you are using at your side. It would help us replicating the issue in our environment and address it accordingly.

// Create TextFragmentAbsorber instance to utilize search capability to search for string tokens.

        TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(

            "\[([^\[\]]*)\]",

            new TextSearchOptions(true));

        textFragmentAbsorber.Visit(documentContainingTokens);

@mkelley

We tried the regular expression which you shared but it did not extract any text from PDF. However, we have tested to replace some text using following code snippet with Aspose.PDF for .NET 20.4 and were unable to notice any issue related to fonts.

var textFragmentAbsorber = new TextFragmentAbsorber();
Document pdfDocument = new Document(dataDir + "CPL_1-GPEPIP_010135473.pdf");
pdfDocument.Pages.Accept(textFragmentAbsorber);
foreach (TextFragment textFragment in textFragmentCollection)
{
 textFragment.TextState.BackgroundColor = Color.Yellow;
 textFragment.Text = "Replaced";
}

Could you please explain a bit more about the issue that you are facing OR please try to share a sample console application which is using latest version of the API and able to reproduce the exception. We will again test the scenario in our environment and address it accordingly.