PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Avoid Line break between paragraphs (in same section)
https://forum.pdfsharp.net/viewtopic.php?f=2&t=3605
Page 1 of 1

Author:  romeoDo [ Tue Jun 20, 2017 5:55 am ]
Post subject:  Avoid Line break between paragraphs (in same section)

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

Author:  Thomas Hoevel [ Tue Jun 20, 2017 7:40 am ]
Post subject:  Re: Avoid Line break between paragraphs (in same section)

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.

Author:  romeoDo [ Tue Jun 20, 2017 10:57 pm ]
Post subject:  Re: Avoid Line break between paragraphs (in same section)

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?

Author:  Thomas Hoevel [ Wed Jun 21, 2017 8:06 am ]
Post subject:  Re: Avoid Line break between paragraphs (in same section)

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.

Author:  romeoDo [ Wed Jun 21, 2017 9:25 am ]
Post subject:  Re: Avoid Line break between paragraphs (in same section)

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

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/