PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Nov 01, 2024 12:12 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: MigrDoc Table in a row?
PostPosted: Fri Apr 04, 2008 5:36 am 
Offline

Joined: Tue Apr 01, 2008 4:41 am
Posts: 6
Is it possible to add a table to a row or cell of another table? I can't seem to find a way to do it.

I have a table of records that are retrieved from a database and each record has a few child records that I need to display in line. the child records have a different number of columns and they are a different width. So I figured a table in a table was the best solution (like in Html code).

Is this possible?

thanks,

-- Nathan Rover


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Apr 07, 2008 7:52 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3111
Location: Cologne, Germany
This can be done and I did it a few months ago, but don't remember the trick.

Don't look for an AddTable method at the table cell. Use "new Table()" and the generic Add method. I don't recall if I added the table directly to the cell or if I added a paragraph to the cell and the table to the paragraph.

Related topic (uses a TextFrame for that purpose which is not generally needed to have nested tables)

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Apr 08, 2008 8:57 pm 
Offline

Joined: Tue Apr 01, 2008 4:41 am
Posts: 6
I've tried to add it to the cell and to a paragraph and I'm getting an error: Overload resolution failed because no accessible 'Add' can be called with these arguments.

here is my code section:

Code:
For Each DTRow As DataRow In Students.Rows
  Dim tbl As New MigraDoc.DocumentObjectModel.Tables.Table()
  tbl.Borders.Width = 0.75

  Column = tbl.AddColumn(MigraDoc.DocumentObjectModel.Unit.FromInch(1.25))
  Column.Format.Alignment = ParagraphAlignment.Center

  Row = tbl.AddRow()
  Cell = Row.Cells(0)
  Cell.AddParagraph(i.ToString())

  Row = Table.AddRow()
  Cell = Row.Cells(0)
  Cell.MergeRight = 5
  Paragraph = Cell.AddParagraph()
  Paragraph.Add(tbl)
  i += 1
Next


The line that causes the error is "Paragraph.Add(tbl)" "tbl" is the name of the table I'm trying to insert in to "table" which is the main table. Each "tbl" will be about 4 or 5 rows, with different columns than the main table. My hope was that if a complete "tbl" did not fit on a page it would move to the next page. I can't figure out how to do that with just one table. Any suggestions?

Thanks,

-- Nathan Rover


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 09, 2008 7:35 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3111
Location: Cologne, Germany
NateDawg wrote:
My hope was that if a complete "tbl" did not fit on a page it would move to the next page. I can't figure out how to do that with just one table. Any suggestions?


I don't recall how I managed to get nested tables when I tried it about two years ago ...

Today I tried it with a textframe in a cell:
Code:
        Cell cell = row1.Cells[0];
        TextFrame tf = cell.AddTextFrame();
        Table table2 = tf.AddTable();
        table2.Borders.Width = 1;
        table2.AddColumn();
        row = table2.AddRow();
        row.Cells[0].AddParagraph("*** Test ***");


This works and should do the trick (if the nested tables are small enough to fit on a page).

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 28, 2011 11:57 am 
Offline

Joined: Fri Feb 25, 2011 2:24 pm
Posts: 4
I faced the same issue. Embedding the nested table within TextField doesn't work, because TextField doesn't grow with the table. There is no way to add Table directly to Cell, but it works, when you add it to Elements collection for Cell:
Code:
cell.Elements.Add(nestedTable);

And this is, how I got it to work. Hope it saves somebody a few hours of time.


Top
 Profile  
Reply with quote  
PostPosted: Fri May 23, 2014 3:30 pm 
Offline

Joined: Fri May 23, 2014 3:27 pm
Posts: 2
DaKo wrote:
I faced the same issue. Embedding the nested table within TextField doesn't work, because TextField doesn't grow with the table. There is no way to add Table directly to Cell, but it works, when you add it to Elements collection for Cell:
Code:
cell.Elements.Add(nestedTable);

And this is, how I got it to work. Hope it saves somebody a few hours of time.

I've registered to this forum just to say THANK YOU!

I'll add a few keywords here so other googler would have easier time finding this:
Nested tables; Table overlap; Overlapping tables;


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 81 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group