PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 9:01 am

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: Tue Jun 20, 2017 5:55 am 
Offline

Joined: Tue Jun 20, 2017 5:47 am
Posts: 3
Hi guys,

Can you please help me to fix this?

Given this simple code

Code:
// Create a new MigraDoc document
       Document document = new Document();
      document.DefaultPageSetup.PageFormat = PageFormat.A3;
         
       // Add a section to the document
       Section section = document.AddSection();

       // Add a paragraph to the section
      Paragraph paragraph = section.AddParagraph("TEST");
         paragraph.Format.KeepTogether = false;
         paragraph.Format.KeepWithNext = true;
         paragraph.Format.PageBreakBefore = true;
      Paragraph paragraph2 = section.AddParagraph("THIS IS A TEST");
         paragraph2.Format.KeepTogether = true;
         paragraph2.Format.KeepWithNext = true;
         paragraph2.Format.PageBreakBefore = true;

      section.AddParagraph("A");
      section.AddParagraph("B");
      section.AddParagraph("C");

      return document;


I tried everything but the option KeepWithNext and KeepTogether seems to be broken. Is there any suggestion?

I don't really want to use table every time for this

P/S: I am working with the latest MigraDoc version (1.50x). I have also tried 1.3x


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 20, 2017 7:40 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
Hi!
romeoDo wrote:
Can you please help me to fix this?
I can not.
I do not understand what you get, I do not understand what you expect.

Title reads "Line break". Is this question about page breaks maybe?

A new paragraph is a new paragraph and there will always be a paragraph break between paragraphs - the new paragraph starts on a new line.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 20, 2017 10:57 pm 
Offline

Joined: Tue Jun 20, 2017 5:47 am
Posts: 3
Thomas Hoevel wrote:
Hi!
romeoDo wrote:
Can you please help me to fix this?
I can not.
I do not understand what you get, I do not understand what you expect.

Title reads "Line break". Is this question about page breaks maybe?

A new paragraph is a new paragraph and there will always be a paragraph break between paragraphs - the new paragraph starts on a new line.


Hi Thomas, I am sorry I should have provided more details on this.

I try to have 2 paragraph in the same section without line break between them. The options KeepWithNex seems to be broken. Are there any suggestions on this?


Top
 Profile  
Reply with quote  
PostPosted: Wed Jun 21, 2017 8:06 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
romeoDo wrote:
I try to have 2 paragraph in the same section without line break between them. The options KeepWithNex seems to be broken. Are there any suggestions on this?
The option is not broken, it is by design that a new paragraph starts on a new line.
KeepWithNext and KeepTogether control page breaks, not line breaks.
You can add several sentences to one paragraph (see "AddFormattedText" at Paragraph class) and add e.g. tab stops between them.

Depending on your needs, a single paragraph - maybe with tab stops - may be enough. You can try tables or text frames. too.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Jun 21, 2017 9:25 am 
Offline

Joined: Tue Jun 20, 2017 5:47 am
Posts: 3
Thomas Hoevel wrote:
romeoDo wrote:
I try to have 2 paragraph in the same section without line break between them. The options KeepWithNex seems to be broken. Are there any suggestions on this?
The option is not broken, it is by design that a new paragraph starts on a new line.
KeepWithNext and KeepTogether control page breaks, not line breaks.
You can add several sentences to one paragraph (see "AddFormattedText" at Paragraph class) and add e.g. tab stops between them.

Depending on your needs, a single paragraph - maybe with tab stops - may be enough. You can try tables or text frames. too.


Thanks for clarification, I had tried those suggestion and it works like charm. Love the idea of Tab stops!!!


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: No registered users and 145 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