clearRunAttrs is deprecated

Hi Team,


docBuilder.clearRunAttrs() method is deprecated in newer version of Aspose.Words (15.5 vs 14.5). What is the alternate method or way for clearing the attributes?

We use docBuilder.clearRunAttrs() at many places… sometimes with docBuilder.getParagraphFormat().clearFormatting() and sometimes without clearFormatting() based on the scenarios.

Thanks,
Kumar

Hi Kumar,

It has been replaced with builder.getFont().clearFormatting(). You should replace all instances of docBuilder.clearRunAttrs() with docBuilder.getFont().clearFormatting().

Best Regards,

Hi Muhammad,


Thanks.

Even DigitalSignatureUtil.sign(String, String, X509Certificate2, String, Date) is deprecated too. What is the new API?

Thanks,
Kumar

Hi Kumar,

It has been replaced with another overload DigitalSignatureUtil.sign(java.lang.String srcFileName, java.lang.String dstFileName, CertificateHolder certificate, java.lang.String comments, java.util.Date signTime) e.g.

CertificateHolder holder = CertificateHolder.create("path of certificate file", "password");

DigitalSignatureUtil.sign(MyDir + "in.docx", MyDir + "Out.docx", holder, "should be signed", new Date());

Best Regards,

Hi Muhammad,


Thanks.

Another question.

Is builder.getFont.clearFormatting() 100% equivalent to builder.clearRunAttrs()?

Thanks,
Kumar

Hi Kumar,

clearRunAttrs is obsolete and it has been replaced with clearFormatting so you can say clearFormatting is the improved version of clearRunAttrs and all issues in clearRunAttrs have also been fixed in clearFormatting.

Please feel free to contact us in case you see any issue.

Best Regards,

Hi Muhammad,


What are the additional actions that clearFormatting() performs when compared to clearRunAttrs()?
Additionally, what were the issues that was addressed with new clearFormatting() API?

Thanks,
Kumar

Hi Kumar,

clearFormatting() resets the font formatting to default. It removes all font formatting specified explicitly on the object from which font was obtained so the font formatting will be inherited from the appropriate parent e.g. Run.getFont().clearFormatting(), DocumentBuilder.getFont().clearFormatting() and Style.getFont().clearFormatting() etc.

You can use this method if you want to reset the font formatting of any object to default. As far as issues fixed are concerned, these issues were specific to a couple of documents where font formatting was not reset properly.

Best Regards,