We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How can I construct a Word doc from multiple docs and keep styles neat and tidy?

Hello, I am doing a proof of concept to research the feasibility of combining multiple Word docs into one, while keeping the list of styles in the combined document neat and tidy. So far I’m not having much luck.


I’ve attached 4 test documents for reference. I am trying to combine these 4 test documents into one document. Background follows:

When I combine the 4 documents using ImportFormatMode.UseDestinationStyles, in the combined document, the “Heading 2” stock Word style, the “Heading 3” stock Word style, and several other stock styles don’t retain all of their style rules. However, the list of styles is nice and neat and tidy. No funky “_0”, “_1”, etc. style names are added to the document.

When I combine the 4 documents using ImportFormatMode.KeepSourceFormatting, in the combined document, the “Heading 2” stock Word style, the “Heading 3” stock Word style, and several other stock Word styles do retain all of their style definitions. So the final document looks ok. But then the process creates all sorts of duplicate style names. I see “Heading 1”, “Heading 1_0”, “Heading 1_1”, etc.

I want the final document to look good/consistent, but I don’t want all of the “Heading 1_0”, “Heading 1_1”, etc. styles created. I expect all of the styles to be defined by name in “1-Title.docm” and then those style names used by all subsequent documents that I combine. How can I accomplish this?

This will be a critical deal breaker for us because, we are researching how can we auto generate Word documents that are hundreds of pages long. Where those generated documents are then edited by our staff. And where we want the generated documents to look good/consistent, but not have hundreds of duplicate style rules. So that our staff don’t see hundreds / thousands of duplicate style names whilst working on their auto generated documents.

I’m not sure if it’s feasible, but that’s the end goal that we’re trying to work toward. Any assistance / source demos of how this can be done would be greatly greatly appreciated!

Thanks
Shan

Hi Shan,


Thanks for your inquiry.

We had already logged a new feature request as WORDSNET-4173. A new import format mode will be added which only creates a new style when conflicting styles are different. This new option will make a copy of the style only when the styles are actually different. You will be notified via this forum thread once this feature is available.

Aspose.Words does not support removing particular styles from documents at the moment. Hopefully, this feature will be available in next version of Aspose.Words. In this case, you can remove duplicate styles from document. The feature ID is WORDSNET-2304.

We apologize for your inconvenience.

Hi Tahir, keeping fingers crossed to see a workaround then in the upcoming release. Timing-wise, when do you think either the workaround, or the new import option, would be available?

Thanks

Hi Shan,


Thanks for posting your issue here in such detail.

Sometimes you will be importing a style into a document that already exists but which has different formatting and this results in a new style with the suffix _0 or _1 created. In order to keep the document looking the same this behavior is required, therefore could you please clarify how you would like the style appearance to remain the same with no new styles being added? For instance would you prefer the formatting applied directly or any new style names created with a different suffix?

Cheers,

Hi Adam, in my scenario, I had used all stock Word styles, and hadn’t changed any of the formatting rules from document to document. Surely this should mean that the stock styles that I applied to all 4 documents use the same set of formatting rules?


In the scenario that you describe, where one might change the formatting rules of a style from document to document, I can understand the need for the “_0”, “_1”, etc. naming convention in order to preserve the styles. Otherwise, how would it be possible to preserve formatting of all documents if one document’s “Heading 1” was red, whereas another document’s “Heading 1” was green? I understand the need in that case. I hope that I was able to articulate the difference to you.

Hi Shan,


Thanks for this additional information - much appreciated. It does sound like UseDestinationStyles is right up your alley. Could you please elaborate on what style rules are not properly maintained when joining documents using this setting?

Cheers,

I thought UseDestinationStyles was right up my alley as well originally. But, it doesn’t work properly.


I’ve attached the output .docx that I created by combining the 4 Word documents from my first post in this thread. The original 4 Word documents are 4 documents that I created using stock Word styles.

If you look at the generated document from this post, file “Assembled-Report.zip”, particularly “heading 2”, and “heading 3”, you will see that they don’t look the same as “heading 2” and “heading 3” from the original document in my first post in “4 test docs.zip”, file “2-cover.docm”.

I’ve also attached 2 screenshots that highlight the visual differences. Let me know if you require any further elaboration on the specific style rules.


Hi Shan,


Thanks for sharing the detail. I have managed to reproduce the same issue at my side. I have logged this issue as WORDSNET-8813 in our issue tracking system. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-2304) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Wow, that was a great turnaround - thank you. I tested it with the isolated test case that I had sent to you, and it worked perfectly. I also tested it with a much larger and complex example, and it seems to be working very well. Thank you for the rapid response time. This will be an excellent project thanks in large part to Aspose.Words.

Hi Shan,


Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.

The issues you have found earlier (filed as WORDSNET-8813) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as WORDSNET-4173) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(2)