Free Support Forum - aspose.com

ImportNode

Dear Sir

I want to copy a section between two document.I found it in your help .

Dim m_Document As Document = New Document("D:\Old.htm")

Dim m_Document1 As Document = New Document("D:\New.doc")

Dim sourceSection As Section = m_Document.Sections(0)

Dim NewSection As Section = CType(m_Document1.ImportNode(sourceSection, True), Section)

m_Document1.Sections(4).AppendContent(NewSection)

m_Document1.Save("D:\New.doc")

It works very well but I have a problem. My text is right to left and the result is a reverse string.I know your component have "Bidi" property for this purpose but I don't know how to set it.

Please tell me how could I do it.

Thanks

Mehdi Mokhtari

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Maybe you should use “ImportFormatMode.KeepSourceFormatting” See the following code snippet.

Dim NewSection As Section = CType(m_Document1.ImportNode(sourceSection, True, ImportFormatMode.KeepSourceFormatting), Section)

Hope this helps. Also please attach your documents for testing.

Best regards.

Hi alexey

Thanks for your quick reply.

I used it but it didn't make any difference in result.

I attach my documents for testing.

I hope you could help me.

Thanks

Mwhdi Mokhtari

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks you for additional information. I think that you can try setting Bidi property for each style in source document. For example see the following code snippet.

'Open source document

Dim srcDoc As Document = New Document("New.htm")

'Set Bidi property for each style in source document

Dim srcStyle As Style

For Each srcStyle In srcDoc.Styles

If (Not srcStyle.Font Is Nothing) Then

srcStyle.Font.Bidi = True

End If

Next

'Open destination document

Dim dstDoc As Document = New Document("0012.doc")

'Get source section

Dim srcSection As Section = srcDoc.Sections(0)

'Import section

Dim dstSection As Section = CType(dstDoc.ImportNode(srcSection, True, ImportFormatMode.KeepSourceFormatting), Section)

'Append content of source section

dstDoc.Sections(4).AppendContent(dstSection)

'Save output document

dstDoc.Save("out.doc")

Hope this helps.

Best regards.