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

Define styles with LineBreak
https://forum.pdfsharp.net/viewtopic.php?f=2&t=2270
Page 1 of 1

Author:  weilah [ Mon Dec 17, 2012 11:49 am ]
Post subject:  Define styles with LineBreak

Hi everybody, this is my first post in the forum. So, first of all i wanna thank you all the team for this amazing and powerful library.

I was wondering (I searched in the forum before asking) if is it possible to define a Style with line breaks in it. Since .SpaceAfter seems to have no results for me. This is the way i define a style:

Code:
        style = document.Styles("Heading1")
        style.Font.Name = "Tahoma"
        style.Font.Size = 15
        style.Font.Bold = True
        style.Font.Color = Colors.DarkBlue
        style.ParagraphFormat.PageBreakBefore = True
        style.ParagraphFormat.SpaceAfter = 15


Thanks

Author:  weilah [ Mon Dec 17, 2012 1:40 pm ]
Post subject:  Re: Define styles with LineBreak

The PageBreakBefore is also not working. What i'm doing wrong? I've tried to create a new style too, with no effects.

Code:
        style = document.AddStyle("MyHeading1", "Heading1")
        style.ParagraphFormat.PageBreakBefore = True
        style.Font.Bold = False
        style.ParagraphFormat.SpaceAfter = "15"



PD: Font color, size, name... are working as spected

Author:  weilah [ Mon Dec 17, 2012 3:56 pm ]
Post subject:  Re: Define styles with LineBreak

I've just figured it out. If the style is used this way:

Code:
        Dim paragraphTitle As DOM.Paragraph = section.AddParagraph()
        paragraphTitle.AddFormattedText("Curabitur libero lacus")
        paragraphTitle.Style = "MyHeading1"


the ParagraphFormat properties defined in the style are ignored, but if you add the paragraph with the style this way, it works as expected:

Code:
      section.AddParagraph("Lore ipsum titolo tiulo", "MyHeading1")


I ignore if this is already defined somewhere in the wiki...i could not find it.

Thanks anyway

Author:  () => true [ Wed Dec 19, 2012 8:08 pm ]
Post subject:  Re: Define styles with LineBreak

Hi!
weilah wrote:
the ParagraphFormat properties defined in the style are ignored
Maybe because the formatted text also has a style. (Could be a feature, not a bug.)
You can use "var para = AddParagraph("Text goes here");" and then set the style of the paragraph.
AddFormattedText is only needed to mix several styles in a single paragraph.

Author:  weilah [ Thu Dec 20, 2012 1:49 pm ]
Post subject:  Re: Define styles with LineBreak

Ok, i understand. And when you use "AddFormattedText", just the "Font" properties of the defined style apply. And the "ParagraphFormat" properties have no effect.

Is that right?

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