Getting Multiple Warning Callbacks for the Same PowerPoint Presentation Font in Java

Hello,

We are using appose total license (aspose-slides-v22.3) for conversion of ppt to PDF document.
We have implemented IWarningCallback to log warnings in our code. While conversion we get a callback for Font Substitution if there is any warning.
But If single font is used at multiple location in document and replaced with substitute font while conversion, we are getting separate callback for every replacement even though same font is replaced.

For Eg: We have “Calibri” font used at 10 locations in ppt document and which is replaced with substitute font then we will get 10 warning callbacks.

Is there any way to get single callback execution for such substitution?

@dnyandevp,
Thank you for describing the issue.

I’ve reproduced the problem with multiple warning callbacks for the same font and added a ticket with ID SLIDESJAVA-39064 to our issue-tracking system. Our development team will consider improving this feature. You will be notified when a new release of Aspose.Slides with the improvement is published.

@dnyandevp,
Our developers have investigated the case. Please use the following code snippet to get a single warning callback for multiple substitutions of a font:

static class SaveWarningCallback implements IWarningCallback {
    Map<Integer, String> warningFilter = new HashMap<Integer, String>();

    @Override
    public int warning(IWarningInfo warning) {
        if (!warningFilter.containsKey(warning.getDescription().hashCode())) {
            warningFilter.put(warning.getDescription().hashCode(), warning.getDescription());
            System.out.println(warning.getDescription());
        }
        return ReturnAction.Continue;
    }
}

You can also check font substitutions as shown below:

Presentation presentation = new Presentation("example.pptx");

for (FontSubstitutionInfo fontSubstitutionInfo : presentation.getFontsManager().getSubstitutions())
{
    System.out.println(fontSubstitutionInfo.getOriginalFontName() + " -> " + fontSubstitutionInfo.getSubstitutedFontName());
}

API Reference: FontsManager class