Free Support Forum - aspose.com

Doc.Clone Loses Formatting

I am using the following code, and it loses a font I have set to Wingdings. Any other way to get a perfect copy?

Dim tempDoc As Aspose.Words.Document = doc.Clone

One more note. Do I need to make a new document and do the append process?

Public Shared Sub AppendDoc(ByRef dstDoc As Document, ByVal srcDoc As Document, ByVal TransactionID As Long, _

ByVal MergeErrNotify As DataStore.MergeErrorNotificationType)

Dim i As Integer = 0

Dim SourceErr As String = " (Source - basMerge,AppenDoc)"

Try

Do While i < srcDoc.Sections.Count

Dim section As Section = CType(dstDoc.ImportNode(srcDoc.Sections(i), True, ImportFormatMode.KeepSourceFormatting), Section)

dstDoc.Sections.Add(section)

If i = 0 Then section.PageSetup.SectionStart = SectionStart.NewPage

i += 1

Loop

Catch ex As Exception

If MergeErrNotify = DataStore.MergeErrorNotificationType.ImmediateMessageBox Then

MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)

Else

DataStore.AuditMerge(DataStore.AcctTransString(TransactionID) & ex.Message & SourceErr, DataStore.AuditType.LocationMergeAudit)

End If

End Try

End Sub

Hi

It is strange. It seems that this code works fine on my side. Also you can try to use the following code snippets.

Dim doc1 As Document = doc.Clone(True)

Or

Dim strm As System.IO.MemoryStream = New System.IO.MemoryStream()

doc.Save(strm, SaveFormat.Doc)

Dim doc1 As Document = New Document(strm)

I hope that it will help you.

Best regards.

The above code will merge two documents. Please tell me what would you like to do?

Best regards.

This code works:

Dim strm As System.IO.MemoryStream = New System.IO.MemoryStream()

doc.Save(strm, SaveFormat.Doc)

Dim doc1 As Document = New Document(strm)

But this code loses the formatting of a WingDings font:

Dim tempDoc As Aspose.Words.Document = doc.Clone

Hi

Please, attach your document for testing. I will try to reproduce this problem and provide you more information.

Best regards.

here is the file

Hi

Thanks for your request. I looked through the attached document and didn’t find any text having Windings font. I concluded that you changed a font in the document programmatically. Please, provide me this code. I will investigate this and provide you more information.

Best regards.