Aspose.Words - There are too many styles in the document

Hi,
we are suffering from the “too many styles” problem as well and successfully used the posted example. Unfortunately the method GenerateStyleStream is far too slow for our needs (we have to call it over and over again). We solved it by calculating a custom hashCode for the Style-objects and use it to determine if we already have such a / the style within our target document. Right now we concatenate the hashCodes of all get*-methods but we have the feeling that we may leave out some deeper referenced objects.
Would it be possible to include a java-conform hashCode()-implementation to the involved classes (Style, ParagraphFormat, ListFormat …)? While debugging I saw a StyleCollection-object which seems to be a key-value-storage for all the inner styles. Maybe the hashCode() could use this object to calculate its value. Unfortunately it’s not accessible from outside the class(es).
Best regards
Klemens Schrage

Hi Klemens,

Thanks for your inquiry.

Did you try using the version of the code here? https://forum.aspose.com/t/114297 This version might be a bit faster.

Right now using the work around, the only way to speed things up would be to use reflection on the style instead of copying it as you are correctly doing.

I’m afraid we don’t often add hash codes to public members as it’s quite hard to generate a meaningful hash for such objects. I think instead it would be better to wait for the original issue to be fixed (an option to allow copying only different styles when appending documents together).

We will keep you informed of any developments.

Thanks,

Hi Adam,
we’re not just concatenating a bunch of documents but merging them with some degree of logic. That’s why the class provided by you is just a basis for what we’re doing in our program. Even the modified version compares two styles by writing a fake document into a ByteArrayOutputStream right?
Basically we’re at the point of importing a node to our target document and try to determine if we should import it with keep-source- or use-destination-style. As I said we’re comparing the styles with the help of a custom calculated hash. I agree with you that it’s hard to find a good hashcode for a certain class. But nevertheless any hashcode which follows the hashcode-rules (in conjunction with equals) would be better than writing the style into a byte-array. The time we required for a midsize document (37 pages) shrinked from around 10 minutes to 30 seconds by just using our - propably not optimal - hashcode.
I secondly agree that the new import-option makes sense. Hopefully it determines equal styles by their hashcodes ;-).
Best regards
Klemens Schrage

Hi Klemens,

Thanks for this additional information.

You are spot on with your analysis. For the time being I think your custom hash code will work for pretty much any situation so it should do for the time being. We will inform you as soon as we release a new import mode and we will also consider providing a hashcode for a style.

If we can help with anything else, please feel free to ask.

Thanks,

Hi,
did you have the same class coded in C# ?
Thank you

Hi there,

Thanks for your inquiry.

Sure, you can find the class in the attachment here: https://forum.aspose.com/t/114297

Thanks,

I have try your class but the issue is still not resolved.

Hi,
I have do some tests.
I currently use the Aspose.Word v11.0.0.0 and this version contain this issue.
If I use the lastest version v9.8.00 this issue disappear.
A date for a newest release ?
Thank you.

Hi there,

Thanks for your inquiry.

Could you please attach your template and sample code here that reproduces the issue? I will take a closer look into this for you.

Thanks,

Hi there,

any news regarding hashCodes and a built-in solution for duplicate style imports? Unfortunately we found a case where our custom hashCode workaround doesn’t solve the problem. It seems to be related with lists where we need the source formatting to ensure the correct numbering and so on.

BTW: Is the maximum style count set by yours or is it a format restriction of doc/rtf/…?
Edit: Found it, as you have already answered this earlier in this thread.

Beste regards
Klemens Schrage

Hi Klemens,

Thanks for your inquiry. I have verified the status of WORDSNET-4173 from our issue tracking system and regret to share with you that this issues has been postponed till a later date. I am afraid, we cannot push this into production right now because there are many other important issues we have to work on. Rest assured, we will inform you as soon as there are any further developments on this. We’re sorry for the inconvenience.

Best Regards,

Hello,
any news on this? We get more and more problems with our homebrew “style collision” checker and end up with some very weird outputs. You guys have the complete overview of what’s going on in this style thing. We can only compare styles on a best guess basis which turns out to be error-prone.
BTW I have problems with the log-in of your site. Chrome and Firefox are not working. The button stays blue. Only IE got it after a few attempts.
Best regards,
Klemens Schrage

Hi Klemens,

Thanks for your inquiry. You are right, there appears to have been many delays in the resolution of this issue. I will get a firm estimate on this feature and provide you some further feedback. We apologize for any inconvenience.

Klemens :
BTW I have problems with the log-in of your site. Chrome and Firefox are not working. The button stays blue. Only IE got it after a few attempts.

I have intimated our web development team of your concern; they will investigate this problem and get back to you soon.

Best regards,

Hi Klemens,

We are sorry for inconvenience regarding your log-in issue on Aspose website.

If you are getting any error when the log-in fails please send us that error. However if you do not get any error then the issue is most likely caused by conflicting browser cookies.

Can you please try after clearing your cookies. Alternatively, you can try a different browser for short time as troubling cookies will auto-expire in your existing browser. Moreover for FireFox or Chrome you can also use any free plugin/add-ons to clear only specific website related cookies.

Hi Awais,

did you get a firm estimate in the meantime? We are struggling with this issue for months and it’s getting more important with every day.

Best regards,
Klemens

Hi Klemens,

We’re sorry for putting you on hold for so long. I’m afraid there isn’t any ETA available yet but we will let you know as soon as there are any developments.

Best regards,

Hi Awais,

our licence file states we have “EditionType: Enterprise”. Any chance to get this covered via it’s SLA? I’m absolutely not sure what depth of support we have to expect. So please take this just as an informational question.

Thanks in advance
Klemens Schrage

Hi Klemens,

Thanks for your inquiry. In case you have “Enterprise Support” subscription, please use your “Enterprise Support” account and post your query in Aspose.Enterprise forum to be able to raise the priority of this issue.

Best regards,

Hello,

isn’t Document.RemoveUnusedStyles introduced in 13.6.0 nearly what we need in this case? Although Style.Remove seems to point into the right direction. However the problem of unintended import of the same style over and over remains.

Unfortunately we’ll be able to pick up new licences (including enterprise support, information in the current licence file was wrong) as early as February '14. Sadly it’s not an option right now, altough we need it urgently.

Best regards
Klemens Schrage

Hi Klemens,

Thanks for your inquiry. Yes, Document.RemoveUnusedResources method was introduced in 13.6.0 which you can use to decrease document size. This method removes unused styles and lists from the document. Secondly, you can use Style.Remove method for removing a particular style from the document. Rest assured, we will inform you as soon as this feature (WORDSNET-4173) is supported. We apologize for your inconvenience.

Best regards,