Hi,
i’m trying to import the content of a sdt of a Document A to a sdt of a Document B using the importNode method, but i 've found two strange behaviors.
- on the origin sdt content i set the word style “Strong” (from Word ribbon bar - Home - Styles), but after import that nodes, in the destination sdt, despite the formatting was kept properly, if i looking for the style, the selected one is “Normal” and not “Strong” as i expected.
- In the origin sdt there was 3 paragraphs and i can selected each of them and change their styles, but in the destination sdt seems to be a single block and i can’t select the paragraphs individually.
Any idea why?
here it is the piece of code, i attach also the source, the destination and the output documents.
public class AsposeImportStyleTest {
public static void main(String[] args) {
try {
Document dstDoc = new Document( "destinationDocumentPath");
Document srcDoc = new Document( "sourceDocumentPath");
Node referencedSdt = srcDoc.getChild(NodeType.STRUCTURED_DOCUMENT_TAG, 0, true);
StructuredDocumentTag sdt = (StructuredDocumentTag)dstDoc.getChild(NodeType.STRUCTURED_DOCUMENT_TAG, 0, true);
sdt.removeAllChildren();
NodeCollection childNodes = ((StructuredDocumentTag) referencedSdt).getChildNodes();
for (Node child: childNodes) {
Node importedNode = dstDoc.importNode(child, true, ImportFormatMode.USE_DESTINATION_STYLES);
sdt.appendChild(importedNode);
}
dstDoc.save("importNodeOuputPath");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}