Free Support Forum - aspose.com

Copying docDefaults from one document to another

Hello,
I am trying to copy docDefaults from one document to anonther. Is there a way to do this with aspose.
I am using the following code to copy styles from one document to another (doc is my target Document and styleDoc is my source):

StyleCollection target = doc.getStyles();
StyleCollection source = styleDoc.getStyles();
for (int i = 0; i < source.getCount(); i++) {
    Style sourceStyle = source.get(i);
    Style targetStyle = target.addCopy(sourceStyle);
    targetStyle.setName(sourceStyle.getName());
}

Hower I also need to copy docDefaults.

The style.xml that im am using as my source to copy styles from contains:

<w:docDefaults>
    <w:rPrDefault>
        <w:rPr>
            <w:rFonts w:ascii="Bookman Old Style" w:eastAsiaTheme="minorHAnsi"
                w:hAnsi="Bookman Old Style" w:cstheme="minorBidi"/>
            <w:sz w:val="40"/>
            <w:szCs w:val="40"/>
            <w:lang w:val="en-NL" w:eastAsia="en-US" w:bidi="ar-SA"/>
        </w:rPr>
    </w:rPrDefault>
    <w:pPrDefault>
        <w:pPr>
            <w:spacing w:after="160" w:line="259" w:lineRule="auto"/>
        </w:pPr>
    </w:pPrDefault>
</w:docDefaults>

And I would like to copy this to the style.xml of my targetDocument.

Regards,
Herman

@avandenhoogen,

Thanks for your inquiry. Unfortunately, Aspose.Words does not support the requested feature at the moment. However, we have logged this feature request as WORDSNET-17056 in our issue tracking system. You will be notified via this forum thread once this feature is available.

We apologize for your inconvenience.

@avandenhoogen,

Thanks for your patience. We have introduced new method Document.CopyStylesFromTemplate in the latest version of Aspose.Words. You can copy defaults with this method. Hope this helps you.