Hi,
We have found one thing that looks as an issue for us. Maybe you can provide a solution or a workaround for this.
The issue is that for example when we have two document
- docx and 2.docx and we set
- in 1.docx Normal style we set font to Arial Black
- in 2.docs Normal style to Snap ITC and then we create a new style TestStyle based on Normal and add a paragraph with some text with style TestStyle
- and then we copy that paragraph from 2.docs to 1.docx using NodeImporter with ImportFormatMode.UseDestinationStyles we would expect the TestStyle to use normal style from the destination document, so with Arial Black not with Snap ITC
Files and code are attached AsposeDemo.zip (29.7 KB)
@acturisaspose Actually the behavior is expected with your documents, since both source and destination documents have TestStyle
. In the destination document, i.e. in 1.docx
TestStyle
has explicitly set font:
<w:style w:type="paragraph" w:customStyle="1" w:styleId="TestStyle">
<w:name w:val="TestStyle"/>
<w:basedOn w:val="Normal"/>
<w:link w:val="TestStyleChar"/>
<w:rsid w:val="00074DAF"/>
<w:rPr>
<w:rFonts w:ascii="Snap ITC" w:hAnsi="Snap ITC"/>
</w:rPr>
</w:style>
So When you import paragraph with TestStyle
applied and ImportFormatMode.UseDestinationStyles, the TestStyle
from the destination document is used. Since font is set explicitly in this style, it is not inherited from Normal
style.
Also, in the source document (2.docx
), the linked character style also has explicitly set font:
<w:style w:type="character" w:customStyle="1" w:styleId="TestStyleChar">
<w:name w:val="TestStyle Char"/>
<w:basedOn w:val="DefaultParagraphFont"/>
<w:link w:val="TestStyle"/>
<w:rsid w:val="00074DAF"/>
<w:rPr>
<w:rFonts w:ascii="Snap ITC" w:hAnsi="Snap ITC"/>
</w:rPr>
</w:style>
but you are right, even if remove explicitly set font in the TestStyle
font is the coped paragraph is Snap ITC
. looks like Aspose.Words expand the inherited formatting of style before copying.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): WORDSNET-25830
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
@acturisaspose We have completed analysis of the issue. Actually, Aspose.Words mimics MS Word here and calculate formatting difference for imported styles.
MS Word has the following formatting after import for the problematic style:
<w:style w:type="paragraph" w:customStyle="1" w:styleId="TestStyle">
<w:name w:val="TestStyle" />
<w:basedOn w:val="Normal" />
<w:link w:val="TestStyleChar" />
<w:qFormat />
<w:rsid w:val="00720854" />
<w:rPr>
<w:rFonts w:ascii="Snap ITC" w:hAnsi="Snap ITC" />
</w:rPr>
</w:style>
<w:style w:type="character" w:customStyle="1" w:styleId="TestStyleChar">
<w:name w:val="TestStyle Char" />
<w:basedOn w:val="DefaultParagraphFont" />
<w:link w:val="TestStyle" />
<w:rsid w:val="00720854" />
<w:rPr>
<w:rFonts w:ascii="Snap ITC" w:hAnsi="Snap ITC" />
</w:rPr>
</w:style>
I.e., MS Word adds into the style <w:rFonts w:ascii="Snap ITC" w:hAnsi="Snap ITC" />
. And in both styles: paragraph and its linked character style. And the bug here is rather the contrary in that Aspose.Words does not do this for the linked character style.
The issues you have found earlier (filed as WORDSNET-25830) have been fixed in this Aspose.Words for .NET 24.4 update also available on NuGet.