Problem with saveOptions.setWarningCallback in 15.4

The suggested solution from :
https://docs.aspose.com/words/java/manipulate-and-substitute-truetype-fonts/

gets marked as deprecated in version 15.4 and is currently not working for me anymore. We used this in prior versions of aspose words to become aware of missing fonts. Is there a suggested approach to do this with the current/future versions of aspose words?

Thanks in advance.

Okay, i figured out that the WarningCallback registration went from the saveoptions to the document itself. Just in case anyone else is looking for this.

But it seems that I have to trigger this somehow myself, since it does not work during document.save()

Hi Scherge,

Thanks for your inquiry. It is nice to hear from you that you have found the Document.WarningCallback property. We will update the shared documentation link according to the latest version of Aspose.Words. We apologize for your inconvenience.

*Grendel:

But it seems that I have to trigger this somehow myself, since it does not work during document.save()*

I have tested this scenario at my side using following code example and have not found any issue. Could you please share your document here for testing?

Document doc = new Document(MyDir + "in.docx");
HandleDocumentWarnings callback = new HandleDocumentWarnings();
doc.setWarningCallback(callback);
doc.save(MyDir + "Out.pdf");

Please find attached a file that should have (at least) 2 unknown fonts.

I debugged into the Handler, it gets called but returns “Compound lines are not supported. Using solid line instead.” several times instead of the (prior expected and received) WarningType.FONT_SUBSTITUTION

Hi Scherge,

Thanks for your inquiry. I have tested this scenario using latest version of Aspose.Words for Java 15.4.0 and have not found any issue with Document.WarningCallback proeprty. Please check the following results. I have used following code example to test this issue. Please use Aspose.Words for Java 15.4.0.

Font substitution: Font ‘Ale and Wenches BB’ has not been found. Using ‘Times New Roman’ font instead.
Font substitution: Font ‘A Yummy Apology’ has not been found. Using ‘Times New Roman’ font instead.
Font substitution: Font ‘Hawaii Killer’ has not been found. Using ‘Times New Roman’ font instead.

Document doc = new Document(MyDir + "UnknownFontPresent.docx");
HandleDocumentWarnings callback = new HandleDocumentWarnings();
doc.setWarningCallback(callback);
doc.save(MyDir + "Out.pdf");
public class HandleDocumentWarnings implements IWarningCallback
{
    public void warning(WarningInfo info)
    {
        // We are only interested in fonts being substituted.
        if (info.getWarningType() == WarningType.FONT_SUBSTITUTION) {
            System.out.println("Font substitution: " + info.getDescription());
        }
    }
}

Thank you Tahir,

i can confirm that the simple scenario works as expected for me here. Now I just need to figure out why in a more complex scenario the font replacement won’t be mentioned anymore in the callback.

Edit: I figured out that I had registered the callback a bit too early, the font warning occured before the time when I finally set the CallbackHandler. I thought that during save operation, all of the warnings would be repeated, but that might not be the case.

Thanks for guiding me the right way

Hi Scherge,

Thanks
for your feedback. It is nice to hear form you that you have figured out your issue. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.