PDFsharp & MigraDoc Forum

PDFsharp - A .NET library for processing PDF & MigraDoc - Creating documents on the fly
It is currently Fri May 16, 2025 5:01 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules

Also see our new Tailored Support & Services site.



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Mon Nov 18, 2024 2:11 pm 
Offline

Joined: Thu Aug 15, 2024 8:44 am
Posts: 5
Hello, all!

I have following problem: I'm creating a pdf document which contains a table with complex header.

The cell in the first row:
-> contains text without line breaks
-> is aligned to the left
-> is merged 1 column to the right
-> the text is "Time"

The cell in the second row:
-> contains text with 2 line breaks
-> is aligned to the right
-> the text is "Timetable\r\nPlan\r\n[hr]"

To get the correct width of the column I get the maximum of the text widths. In the second row I split the text via Environment.NewLine and measure each part separately.
Finally I add left/right padding of the cell and width of left/right borders and get the resulting column width.

Now the problem: after setting column width to the resulting value and rendering, the cell with line breaks gets an additional line break: after "Timetable". It literally looks like:
-----------
Time
-----------
Timetable

........Plan
........[hr]
-----------

(sorry for dots - spaces are not displayed in the final post)

If I add 4 points to the width the automatic line break disappears. But (!!!) in this case the first word "Timetable" gets 4 point indentation to the right due to the column right alignment.
-----------
Time
-----------
.Timetable
........Plan
........[hr]
-----------

I think it is the line break that is not displayed, but is somehow calculated increasing needed column width while rendering.

My first idea was to split the problematic cell into 3 rows and fill in the three strings separately, but it would be really the plan B, because it increases the hight of the table header and place is important.

Has anyone any ideas how could I handle this issue?
Thanks in advance!


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 20, 2024 2:52 pm 
Offline
PDFsharp Guru
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 1044
Location: CCAA
firelex wrote:
Has anyone any ideas how could I handle this issue?
I would make the cell in the second row left-aligned and use a right-aligned tabstop for the second and third line of text.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


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

All times are UTC


Who is online

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