PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Apr 27, 2024 2:04 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Fri May 16, 2014 2:22 pm 
Offline

Joined: Tue Apr 29, 2014 10:21 am
Posts: 27
Rows seem to have a standard height.
I want to add a spacer row to put space between 2 tables but of less than the standard height.

Code:
  Dim spacerRow = tabDimensions.AddRow()
        spacerRow.Height = "0.2cm"


This height setting has no effect. The row height is the same as the default.


Top
 Profile  
Reply with quote  
PostPosted: Sat May 17, 2014 11:41 am 
Offline
PDFsharp Expert
User avatar

Joined: Wed Dec 09, 2009 8:59 am
Posts: 340
I do not see two tables in your code, I only see a single table row.

Please provide more code and/or an MDDDL file.
http://pdfsharp.net/wiki/MigraDocDDL.ashx

_________________
Öhmesh Volta ("() => true")
PDFsharp Team Holiday Substitute


Top
 Profile  
Reply with quote  
PostPosted: Mon May 19, 2014 8:39 am 
Offline

Joined: Tue Apr 29, 2014 10:21 am
Posts: 27
Note, there is nothing in the style definition mentioning row height either.

Code:
dynamic tabDimensions = _sec.AddTable();
tabDimensions.BottomPadding = 3;
tabDimensions.TopPadding = 3;
tabDimensions.AddColumn("8.6cm");
tabDimensions.AddColumn("2.0cm");
tabDimensions.AddColumn("1.4cm");
tabDimensions.AddColumn("2.4cm");
tabDimensions.AddColumn("1.2cm");
tabDimensions.AddColumn("2.4cm");
tabDimensions.AddColumn("1cm");

tabDimensions.Borders.Width = 0.5;
tabDimensions.Borders.Color = Colors.Black;

tabDimensions.Borders.Visible = false;
// toggle for testing



dynamic headingsRow = tabDimensions.AddRow();

dynamic hdr1RowPara = headingsRow.Cells(1).AddParagraph();
headingsRow.Cells(1).Format.Alignment = ParagraphAlignment.Center;
hdr1RowPara.Format.Font.Size = 8;
hdr1RowPara.Format.Font.Bold = true;
hdr1RowPara.AddText("Area (m²)");


dynamic hdr3RowPara = headingsRow.Cells(3).AddParagraph();
headingsRow.Cells(3).Format.Alignment = ParagraphAlignment.Center;
hdr3RowPara.Format.Font.Size = 8;
hdr3RowPara.Format.Font.Bold = true;
hdr3RowPara.AddText("Av.Height (m)");


dynamic hdr5RowPara = headingsRow.Cells(5).AddParagraph();
headingsRow.Cells(5).Format.Alignment = ParagraphAlignment.Center;
hdr5RowPara.Format.Font.Size = 9;
hdr5RowPara.Format.Font.Bold = true;

hdr5RowPara.AddText("Volume (m²)");



dynamic floor0Row = tabDimensions.AddRow();

floor0Row.Cells(0).AddParagraph.AddText("Ground floor");
floor0Row.Cells(0).Borders.Visible = false;

dynamic cellR0C1 = floor0Row.Cells(1).AddParagraph();
cellR0C1.Format.Alignment = ParagraphAlignment.Center;
cellR0C1.AddText(_pd.gdPlanDetailsFinancials.rescheduleChargeAmount.ToString);
floor0Row.Cells(1).Borders.Visible = true;
floor0Row.Cells(1).Borders.Width = 1;



// Gap row >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
dynamic spacerRow = tabDimensions.AddRow();
spacerRow.Height = "0.2cm";


dynamic tabVent = _sec.AddTable;
tabVent.BottomPadding = 3;
tabVent.TopPadding = 3;
tabVent.AddColumn("4.5cm");
tabVent.AddColumn("1.8cm");
tabVent.AddColumn("0.8cm");
tabVent.AddColumn("1.8cm");
tabVent.AddColumn("0.8cm");
tabVent.AddColumn("1.8cm");
tabVent.AddColumn("0.7cm");
tabVent.AddColumn("1.8cm");
tabVent.AddColumn("1.8cm");
tabVent.AddColumn("2.4cm");
tabVent.AddColumn("0.8cm");

tabVent.Borders.Width = 0.5;
tabVent.Borders.Color = Colors.Black;

tabVent.Borders.Visible = false;

dynamic rowVenRatHdr = tabVent.AddRow;
dynamic paraVentRateHd = rowVenRatHdr.Cells(0).AddParagraph;
rowVenRatHdr.Shading.Color = _sectionTitleBgColour;
paraVentRateHd.Style = "Heading4";
paraVentRateHd.Format.Alignment = ParagraphAlignment.Left;
paraVentRateHd.AddText("2. Ventilation rate:");


Top
 Profile  
Reply with quote  
PostPosted: Mon May 19, 2014 2:27 pm 
Offline
PDFsharp Guru
User avatar

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

I tried two different things.

My first approach: a spacer paragraph (not a spacer row):
Code:
Table t1 = section.AddTable();
t1.AddColumn(Unit.FromCentimeter(15));
var row1 = t1.AddRow();
t1.Borders.Width = 0.5;

var para = section.AddParagraph();
para.Format.LineSpacingRule = LineSpacingRule.Exactly;
para.Format.LineSpacing = "0.2cm";
para.Format.SpaceBefore = 0;
para.Format.SpaceAfter = 0;

Table t2 = section.AddTable();
t2.AddColumn(Unit.FromCentimeter(12));
var row2 = t2.AddRow();
t2.Borders.Width = 0.5;


Setting the height of the spacer row worked for me only after adding a paragraph:
Code:
Table t1 = section.AddTable();
t1.AddColumn(Unit.FromCentimeter(15));
var row1 = t1.AddRow();
t1.Borders.Width = 0.5;

var spacerRow = t1.AddRow();
spacerRow.Height = "0.2cm";
var para2 = new Paragraph();
para2.Format.LineSpacingRule = LineSpacingRule.Exactly;
para2.Format.LineSpacing = "0.2cm";
para2.Format.SpaceBefore = 0;
para2.Format.SpaceAfter = 0;
spacerRow.Cells[0].Add(para2);

Table t2 = section.AddTable();
t2.AddColumn(Unit.FromCentimeter(12));
var row2 = t2.AddRow();
t2.Borders.Width = 0.5;
My table only has a single column and it worked after adding a paragraph to that column. It could be that this trick requires such spacer paragraphs in all columns. Could be a bug.
Setting the spacer row to a height of "2cm" does work, but "2mm" does not work (it seems it uses the height of a text line by default even though there is no text in that row).

Two solutions, which one is better? The spacer row - you can set "row1.KeepWith = 1;" for the row preceding the spacer row to prevent having the spacer row as the first row on a new page after a page break (currently you cannot prevent this with a spacer paragraph between two tables).

BTW: When exporting to RTF you will need a paragraph between the two tables. This can be a paragraph with a height of 0.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue May 20, 2014 3:03 pm 
Offline

Joined: Tue Apr 29, 2014 10:21 am
Posts: 27
Using the first method seems to make a difference, if not exactly correct. (It doesn't look like 0.2cm)
Anyway, it is a "nice to have" rather than a "show stopper" issue.

Thanks.


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

All times are UTC


Who is online

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