table in a table

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for COM/ActiveX (v8)  /  Re: table in a table

DynamicPDF CoreSuite for COM/ActiveX (v8) Forum

 Jul 09 2016 10:00 PM
I need to insert a table in the row of another table.  So TableA has 4 rows and in row 3 I want to insert TableB.

I assumed that when you placed a table inside another table, you would use x and y = 0,0 to reference the top left coordinate of TableA, Row3, but not so...

   Set TableSC11 = MyPageSC1.AddTable(0, 0, 518, 640)

This put the new table at the top-left of the page, not of TableA Row3.

So, how can I determine dynamically where the top left is of TableA Row3?  Note: Row 2 can vary in length of content so the top of row 3 will also vary, so I need to know dynamically where top of row 3 is.

Thanks.
 Jul 14 2016 1:03 PM
Posted by a ceTe Software moderator
Hello,

You are using the correct coordinates for your requirement. However, in your code you are adding TableB to the page itself so the result (TableB added at the top left corner of the page) you are seeing is expected.

In order to add TableB within TableA, you don’t have to dynamically determine the top left of the TableA Row3. You would just add TableB to the cell of Row 3 of TableA. This would add TableB with respect to the top left corner of the cell of TableA Row3. Here is the sample code: 

    Dim MyDocument As DynamicPDF.Document
    Set MyDocument = New DynamicPDF.Document
    Dim MyPage
    Set MyPage = MyDocument.AddPage()
    Dim MyTable As Table2
    Set MyTable = MyPage.AddTable2(0, 0, 400, 50)
    
    Dim Column1
    Set Column1 = MyTable.AddColumn2(210)
    Dim Column2
    Set Column2 = MyTable.AddColumn2(100)
    
    Dim Row1
    Set Row1 = MyTable.AddRow2()
    Row1.AddCell2 "Column #" & 1
   Row1.AddCell2 (" Main table Item1")
    
    'Adding Inner table to the cell of the Main table.
    Dim MyRow2 As DynamicPDF.Row2
    Set MyRow2 = MyTable.AddRow2()
    Dim MyCell1 As DynamicPDF.Cell2
    Set MyCell1 = MyRow2.AddCell2()
    'Build inner table.
    Dim MyInnerTable As Table2
    Set MyInnerTable = MyCell1.SetTable2(0, 0, 200, 50)
    Dim InnerTableColumn1
    Set InnerTableColumn1 = MyInnerTable.AddColumn2(100)
    Dim InnerTableColumn2
    Set InnerTableColumn2 = MyInnerTable.AddColumn2(100)
    
    Dim InnerTableRow1
    Set InnerTableRow1 = MyInnerTable.AddRow2()
    InnerTableRow1.AddCell2 "Inner table item 1"
    InnerTableRow1.AddCell2 ("Inner table item 1")
    
    For i = 2 To 4
    Dim InnerTableRow2
    Set InnerTableRow2 = MyInnerTable.AddRow2()
    InnerTableRow2.AddCell2 "Inner table item " & i
    InnerTableRow2.AddCell2 ("Inner table item " & i)
    Next
    MyInnerTable.Height = MyInnerTable.GetRequiredHeight()
       
    MyRow2.AddCell2 ("Mian table Item2")
    MyTable.Height = MyTable.GetRequiredHeight()
  
    Do
    Set MyTable = MyPage.AddOverflowTable2(MyTable)
    Set MyTable = MyTable.GetOverflowColumns(50, 50, 250, 50)
    If MyTable Is Nothing Then
    Exit Do
    End If
    Set MyPage = MyDocument.AddPage()
    Loop
    MyDocument.DrawToFile ("C:\HelloWorld.pdf")

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 7:03 AM.