Bug : RadFlowDocument generates execption when calling Clone

1 Answer 100 Views
WordsProcessing
Edwin
Top achievements
Rank 1
Edwin asked on 07 Oct 2022, 01:18 PM | edited on 07 Oct 2022, 01:18 PM

When using the Clone function from RadFlowDocument, the below exception is thrown :

[2022-10-07T13:06:32.329Z] Error: System.ArgumentException: The document element is associated with another document. (Parameter 'item')
   at Telerik.Windows.Documents.Flow.Model.Collections.DocumentElementCollection`2.VerifyDocumentElementOnInsert(T item)
   at Telerik.Windows.Documents.Flow.Model.Collections.DocumentElementCollection`2.AddClonedChildrenFrom(DocumentElementCollection`2 fromCollection, CloneContext cloneContext)
   at Telerik.Windows.Documents.Flow.Model.Paragraph.CloneCore(CloneContext cloneContext)
   at Telerik.Windows.Documents.Flow.Model.Collections.DocumentElementCollection`2.AddClonedChildrenFrom(DocumentElementCollection`2 fromCollection, CloneContext cloneContext)
   at Telerik.Windows.Documents.Flow.Model.Footer.CloneCore(CloneContext cloneContext)
   at Telerik.Windows.Documents.Flow.Model.HeadersFootersBase`1.CloneHeadersFootersFrom(HeadersFootersBase`1 headersFooters, CloneContext cloneContext)
   at Telerik.Windows.Documents.Flow.Model.Section.ClonePropertiesAndHeadersFooters(CloneContext cloneContext)
   at Telerik.Windows.Documents.Flow.Model.Section.CloneCore(CloneContext cloneContext)
   at Telerik.Windows.Documents.Flow.Model.Collections.DocumentElementCollection`2.AddClonedChildrenFrom(DocumentElementCollection`2 fromCollection, CloneContext cloneContext)
   at Telerik.Windows.Documents.Flow.Model.RadFlowDocument.CloneCore(CloneContext cloneContext)
   at Telerik.Windows.Documents.Flow.Model.RadFlowDocument.Clone()
   at Perspex.Shared.OOPGenerator.OOPGenerator.SetWordDocumentTemplate(Schools school, SchoolYear schoolyear) in D:\projecten\cip\Perspex\src\Perspex.Shared\OOPGenerator\OOPGenerator.cs:line 62

It occurs after I upgraded to the latetst version of RAD Document processing. In the previous version it worked as expected.

Steps I take to reproduce the issue :

1) Load a word document
2) Clone the document.

    WordDocumentTemplate = await Storage.GetWordDocumentTemplate(school.Onderwijstype, schoolyear);
    if (WordDocumentTemplate!= null)
    {
      WordDocument = WordDocumentTemplate.Clone(); <-- throws the exception

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 11 Oct 2022, 08:55 AM

Hi Edwin,

We have a known issue with this which looks similar: WordsProcessing: NullReferenceException cloning Table element into RadFlowDocument

I cannot confirm without testing this with the document. Would it be possible to open a new support ticket and attach the document? 

As a workaround, I can suggest using the Import method to create a new instance of the document instead of cloning it.

Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Edwin
Top achievements
Rank 1
commented on 11 Oct 2022, 01:13 PM

Hi Dimitar,

I have posted a new support ticket and also reported this as a bug.

With the previous version I have had no problems using the same documents.

Dimitar
Telerik team
commented on 12 Oct 2022, 08:48 AM

Hi,

Ok, thanks. We can continue to discuss this in the ticket. 

Tags
WordsProcessing
Asked by
Edwin
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or