PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Mon Dec 10, 2018 10:52 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Mon Oct 15, 2018 9:56 am 
Offline

Joined: Mon Nov 06, 2017 3:53 pm
Posts: 18
Hello,
I've currently a small problem with negative numbers which I add into my table.

Let me explain:
I got a table with 4 columns each of those columns are fixed width (widening the columns is not an option for my purpose). I'm reading numbers form a ASCII file some of them are positive and some negative.
However if there is a long negative number which will exceed it's column width the migradoc internal 'intelligence' will add a linebreak to the paragraph.

Can I disable this feature to get the number in one line?
Replacing the hyphen with something similar looking does not sound like a good idea.

Here is how I add the paragraph:

Code:
                    cell = DRow.Cells[1];
                    p = new Paragraph();
                    p.AddFormattedText(input, TableFont);
                    cell.Add(p);


Thank you!


Top
 Profile  
Reply with quote  
PostPosted: Mon Oct 15, 2018 11:15 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2893
Location: Cologne, Germany
Hi!
OVS wrote:
Replacing the hyphen with something similar looking does not sound like a good idea.
That would be a simple workaround that surely works.

But then you'll get the next problem: the number does not fit the column - otherwise the "MigraDoc intelligence" would not break at the minus. The number will be drawn across the column margin, maybe into the next column.

A clean solution would be using wider columns - or a smaller font or maybe a narrow font.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Oct 15, 2018 11:46 am 
Offline

Joined: Mon Nov 06, 2017 3:53 pm
Posts: 18
I've now wrote a method which will measure the string before putting it into the cell. If it is to wide for the cell it will decrease the font size step by step.
It is a recursive method. It will break the recursive loop if the string fits. After that it will set the font back to its original size.

However this still ignores the hyphen (calculation of measured string size) and does not take it into its calculation.

I used the helper class I've found here in the forums to measure the needed space.

However I could set a threshold to do maybe one or two additional recursive calls to further decrease the font in size.


Top
 Profile  
Reply with quote  
PostPosted: Mon Oct 15, 2018 3:01 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2893
Location: Cologne, Germany
OVS wrote:
However this still ignores the hyphen (calculation of measured string size) and does not take it into its calculation.
I used the helper class I've found here in the forums to measure the needed space.
Could be a bug if the minus is not included in the size calculation.
Would you please provide a link to the helper class?

See also:
http://forum.pdfsharp.net/viewtopic.php?f=2&t=832

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 16, 2018 6:47 am 
Offline

Joined: Mon Nov 06, 2017 3:53 pm
Posts: 18
Sure:

viewtopic.php?f=8&t=3196&p=11662&hilit=TextMeasurement#p11662

Using a 1:1 copy of that.


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 16, 2018 11:20 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2893
Location: Cologne, Germany
Thanks for the link.

And which version of PDFsharp? 1.50 RC2a? GDI+ build? WPF build?


AFAIK the part of the column used for text is smaller than the width of the column due to the margins of the column.
Did you take the margins into account when comparing text width and column width?

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 16, 2018 2:25 pm 
Offline

Joined: Mon Nov 06, 2017 3:53 pm
Posts: 18
1.50.4740.0 GDI+ build (release)

I take the cell width into account by using this:
Code:
cell.Column.Width



So I guess the margins are not included into the calculation. Now I have to find a way to get the margin for the column I'm currently putting text into.

cell.LeftPadding and cell.RightPadding are set to 0. I added them to the 'available space' anyway. However the behaviour does not change. What's the margin property of the cell?


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 8 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