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

Free Support Forum - aspose.com

Merge another docx file in place of Content contol

Hi

my requiremnt is merging the docx files. I have 3 docx fiels, those are Main, sub1, sub2. Main doucment has 2 content controls. sub1 document need to be merge in place of first ContentControl, sub2 document need to be merge in place of second content control.

please provide me the piece of code how to merge docx file in place of content control.

Thanks in advance

Bhanuprasad

I am using .Net 3.5 to develop this piece of code.

thanks

Bhanuprasad

Hi there,

Thank you for posting on the forums. As I stated in live support, Aspose.Words currently doesn't support content controls. We will keep you informed of any developments regarding this issue. Most likely this feature is due to be supported in the version due out sometime in late August.

In the mean time as you stated you were doing, you should use the equivalent function in Aspose.Words instead, which is InsertDocument to achieve the same behaviour. The problem was you were unable to find the position of the content control. I'm afraid since content controls are not yet supported this is not possible right now.

However I have noticed that some content controls do tend to include a section break in them. If this is the case you could search for the paragraphs with these breaks which would give you the position to insert your document into.

Please see the code below which achieves this.

Document doc = new Document("ContentControl Template.doc");<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Document doc2 = new Document("SubDocument1.doc");

NodeCollection paragraphs = doc.GetChildNodes(NodeType.Paragraph, true);

foreach (Paragraph para in paragraphs)

{

//Use GetText() to include control characters as well.

string text = para.GetText();

if (text.Contains(ControlChar.SectionBreak))

{

//Inserting the document at the paragraph containing the section break seems to cause problems.

//Instead remove it and insert a temp paragraph. This assumes that the only content in the paragraph is

//the content control. This part may need to be reworked if this is not the case.

Paragraph tempPara = new Paragraph(doc);

para.ParentNode.InsertAfter(tempPara, para);

para.Remove();

InsertDocument(tempPara, doc2);

}

}

If this does not help then please post your template here and we will see if there is any other way that this could be achieved.

Thanks,

The issues you have found earlier (filed as 4295) have been fixed in this update.


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