Calling .TableInsert in a loop = The document element is associated with another parent

3 posts, 0 answers
  1. Dan
    Dan avatar
    124 posts
    Member since:
    Feb 2011

    Posted 13 Jul 2015 Link to this post

    I am trying to create a multi-section PDF report and am getting this error when doing the second .InsertTable:

    System.ArgumentException: The document element is associated with another parent.

    Something like this:

    var pdfDocument = new RadFixedDocument()
    {
        DocumentInfo =
        {
            Title = packageTitle,
            Author = packageRunBy
        }
    };
    pdfDocument.Destinations.AddPageHorizontalFit();
    var pdfEditor = new RadFixedDocumentEditor(pdfDocument);

    foreach (var report in reports)
    {

    if (pdfDocument.Pages.Count > 0) pdfEditor.InsertSectionBreak();

    var reportTable = new Table();

    // Build the Table

    pdfEditor.InsertTable(reportTable); // Errors here on the second time around the loop

    }

  2. Dan
    Dan avatar
    124 posts
    Member since:
    Feb 2011

    Posted 14 Jul 2015 in reply to Dan Link to this post

    Oddly the error has gone away - It may have been related to some TextFragements or Blocks having blank values
  3. Petya
    Admin
    Petya avatar
    975 posts

    Posted 16 Jul 2015 Link to this post

    Hello Dan,

    We're aware of a similar issue when the table needs to be split on several pages. As you presumed, it highly depends on the content of the document as it occurs due to wrong calculation of the table's height in the splitting logic.

    Resolving this is in our backlog and you can track the team's progress here.

    Regards,
    Petya
    Telerik
Back to Top