PDFsharp & MigraDoc Forum

PDFsharp - A .NET library for processing PDF & MigraDoc - Creating documents on the fly
It is currently Fri Jun 13, 2025 1:07 am

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 Jun 02, 2025 2:08 pm 
Offline

Joined: Mon Jun 02, 2025 1:56 pm
Posts: 1
Hi all,

I’m using MigraDoc to render formatted text into a PDF, and I’ve encountered an issue with line breaks inside table cells.

In our WPF application, we use MigraDoc to generate PDFs from rich text input. Users often press Shift+Enter to insert a line break (without starting a new paragraph). We’re seeing unexpected behavior in the generated PDF: line breaks added via Shift+Enter seem to be collapsed or ignored — but only when they occur without text directly before them.

Input in the app (typed in a table cell):
Quote:
abc
<Shift+Enter>
def
<Shift+Enter>
<Shift+Enter>
<Shift+Enter>
ghi


Expected output in pdf:
Quote:
abc
def


ghi


Actual output:
Quote:
abc
def
ghi


The three AddLineBreak() calls between def and ghi seem to be collapsed (only one line shown).

It appears that if the paragraph has no text content, MigraDoc silently skips the line break.
Is this the intended behavior in MigraDoc? Is there official documentation or a GitHub issue explaining why line breaks are ignored unless the paragraph already contains content?
Any confirmation or workaround recommendations would be greatly appreciated.

Thanks!


Top
 Profile  
Reply with quote  
PostPosted: Wed Jun 04, 2025 11:05 am 
Offline
PDFsharp Guru
User avatar

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

You mention Shift+Enter at the top and AddLineBreak at the bottom of your post.

Line breaks added with AddLineBreak should not be ignored.
Whitespace may be trimmed from strings and it is not recommend to use "\r" or "\n" in strings.

You can use the IssueSubmissionTemplate to submit a project that allows us to replicate the issue.
https://docs.pdfsharp.net/General/Issue ... About.html

_________________
Regards
Thomas Hoevel
PDFsharp Team


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 37 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