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

Free Support Forum - aspose.com

Issues with Importformatmode Styles and content controls


I have 2 issues with Aspose that don't allow me to go forward at work. I was hoping you could help me with those.

Issue 1. I am copying the content (a paragraph to be precise) of a content control of a document A to the content of a content control of a document B. When copying styles we need to create new styles only when they do not match the styles on the destination document, so I am using ImportFormatMode.KeepDifferentStyles for that when using ImportNode.

The paragraph I am copying has the "Normal" style, and in both documents this "Normal" style is identical (Generis Sans Com, 12, Line spacing: single, space after and before the paragraph: 0pt). However, after importing the node with ImportFormatMode.KeepDifferentStyles and appending it to the content control of the destination document, a new style is created (with ImportFormatMode.KeepDifferentStyles and being the same style in both documents it should just refer to the "Normal" style instead of creating "Normal_0") and also this new style is exactly the same as the "Normal" style but the line spacing is 1.15pt and the space after the paragraph is set to 10pt. I think there might be a bug in Aspose when you have default values (single line spacing and 0pt space before and after the paragraph) or just when the style is identical in both documents, as when I change those values it seems to be copying them as a new style as it should. Plus, if I use ImportFormatMode.KeepSourceFormatting seems to be working fine with default values. Could you let me know if I am missing something here or might be a problem from Aspose?

Issue 2. I have 4 content controls in the destination document, 1 of them is not a full paragraph. I am Importing + appending the same paragraph to all of them and in the normal content controls it works fine, but when trying to append the paragraph (after doing ImportNode) to the content control that does not span a whole paragraph I am getting the following exception "System.ArgumentException: Cannot insert a node of this type at this location.". Is there a way to insert content inside content controls that do not span a whole paragraph?

Thank you for your time.
Hi there,

Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word documents
  • Please attach the output Word documents that shows the undesired behavior.
  • Please share the screenshots of problematic sections of output documents.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we'll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip them and Click 'Reply' button that will bring you to the 'reply page' and there at the bottom you can include any attachments with that post by clicking the 'Add/Update' button.