PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Apr 26, 2024 7:21 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Aug 24, 2009 7:28 pm 
Offline

Joined: Mon Apr 27, 2009 12:33 pm
Posts: 7
MigraDoc Foundation, WPF build, 1.30

I tried to use a column layout and i found in other posts that this should be done using a table.
Then i need to add a table in the columns and to do that i added a TextFrame and added the table to the text frame. When using TextFrames incide the columns to get some special formatting or allignment then the size of the height of the rows where the TextFrame is gets totaly wrong and you get overlapping tables.
Code to replicate this:

Document doc = new Document();
doc.AddSection();

Table layoutTable = new Table();
layoutTable.AddColumn(200);
layoutTable.AddRow();

Table innerTable = layoutTable[0, 0].AddTextFrame().AddTable();
innerTable.AddColumn(150);

innerTable.AddRow();
innerTable[0, 0].AddTextFrame().AddParagraph("TESTING WITH TEXT FRAME LONG PARAGRAPH TO SEE HOW IT WORKS");

innerTable.AddRow();
innerTable[1, 0].AddTextFrame().AddParagraph("TESTING WITH TEXT FRAME LONG PARAGRAPH TO SEE HOW IT WORKS");

layoutTable.AddRow();

innerTable = layoutTable[1, 0].AddTextFrame().AddTable();
innerTable.AddColumn(150);

innerTable.AddRow();
innerTable[0, 0].AddParagraph("testing a long paragraph to make it wrap, this should do");

innerTable.AddRow();
innerTable[1, 0].AddParagraph("testing a long paragraph to make it wrap, this should do");
doc.LastSection.Add(layoutTable);


Attachments:
overlappingTables.jpg
overlappingTables.jpg [ 37.17 KiB | Viewed 10729 times ]
Top
 Profile  
Reply with quote  
PostPosted: Tue Aug 25, 2009 7:58 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
Hi!

I think it's not a bug, it's a feature.

You don't need to use TextFrames in your inner table:
Code:
innerTable.AddRow();
innerTable[0, 0].AddTextFrame().AddParagraph("TESTING WITH TEXT FRAME LONG PARAGRAPH TO SEE HOW IT WORKS");

innerTable.AddRow();
innerTable[1, 0].AddTextFrame().AddParagraph("TESTING WITH TEXT FRAME LONG PARAGRAPH TO SEE HOW IT WORKS");


You neither specify the width of the textframe nor its position. See the Left and RelativeHorizontal properties of the TextFrame.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 28, 2009 11:39 am 
Offline

Joined: Mon Apr 27, 2009 12:33 pm
Posts: 7
Hi Thomas,

I still get overlapping elements. Please see the code below. I am only using the TextFrame to be able to add the nested table.
In case you have a column layout and you use 2 columns(or more i guess). I see this behaviour comming especially when long text wrapping inside the cell.
Attached also a screen shot

Below is the code for getting the described behavior.

Thanks for your quick answers.
Best Regards,
Sofoklis

Document doc = new Document();

doc.AddSection();

Table layoutTable = new Table();

layoutTable.AddColumn(200);
layoutTable.AddColumn(200);
TextFrame tf;
layoutTable.AddRow();

Table innerTable = layoutTable[0, 0].AddTextFrame().AddTable();
innerTable.Borders.Style = BorderStyle.Single;
innerTable.Borders.Color = Colors.Red;
innerTable.AddColumn(150);
innerTable.AddRow();
innerTable[0, 0].AddParagraph("TESTING WITH TEXT FRAME LONG PARAGRAPH TO SEE HOW IT WORKS");

innerTable.AddRow();
innerTable[1, 0].AddParagraph("TESTING WITH TEXT FRAME ");

innerTable = layoutTable[0, 1].AddTextFrame().AddTable();
innerTable.Borders.Style = BorderStyle.Single;
innerTable.Borders.Color = Colors.Red;
innerTable.AddColumn(150);
innerTable.AddRow();
innerTable[0, 0].AddParagraph("TESTING WITH TEXT FRAME LONG PARAGRAPH TO SEE HOW IT WORKS dsdfsdf sdfsddfs sdfsdfsdf sdfsdfsdf fsdfsdfsfsd sfdfsdfsd");

innerTable.AddRow();
innerTable[1, 0].AddParagraph("TESTING WITH TEXT FRAME ");

layoutTable.AddRow();

tf = layoutTable[1, 0].AddTextFrame();
innerTable = tf.AddTable();

innerTable.Borders.Style = BorderStyle.Single;
innerTable.Borders.Color = Colors.Blue;
innerTable.AddColumn(150);
innerTable.AddRow();
innerTable[0, 0].AddParagraph("testing a long paragraph to make it wrap, this should do");

innerTable.AddRow();
innerTable[1, 0].AddParagraph("testing a long paragraph to make it wrap, this should do");



tf = layoutTable[1, 1].AddTextFrame();
innerTable = tf.AddTable();

innerTable.Borders.Style = BorderStyle.Single;
innerTable.Borders.Color = Colors.Blue;
innerTable.AddColumn(150);
innerTable.AddRow();
innerTable[0, 0].AddParagraph("testing a long paragraph to make it wrap, this should do");

innerTable.AddRow();
innerTable[1, 0].AddParagraph("testing a long paragraph to make it wrap, this should do");

doc.LastSection.Add(layoutTable);

PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always);
renderer.Document = doc;

renderer.RenderDocument();


Attachments:
NestedTableOverlap.png
NestedTableOverlap.png [ 47.32 KiB | Viewed 10717 times ]
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 322 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