Document Layout Tutorials
PageElement Abstract Class
Frame : PageElement Class
TextBlock : PageElement Class
ImageBlock : PageElement Class
Box : PageElement Class
Rule : PageElement Class
Widow and Orphan Control
SharpLeaf provides simple ParagraphStyle settings to prevent odd paragraph splitting across page or frame boundary.
Keeping lines together
The default setting produces a single line on its own at the top of the second frame.
Setting the Keep to two make the text flow slightly nicer, as the penultimate line is pushed onto the second frame although it could fit in the first.
In this case it is impossible to keep 3 lines together on each side of the frame skip, so the whole paragraph is started on the next frame. This is why Keep values are generally low – they quickly produce a lot of blank space at the end of frames.
Ensuring space available at the start of end of a paragraph
Here’s a example of a Title paragraph that fits right at the bottom of a frame. Its subject paragraph ends up on the next frame.
The Keep setting will not address this problem as no paragraph is split across frames. The ParagraphStyle class provides two properties that address it:
See the visual glossary for an illustration.
// Skip to next frame if less than 4 lines available at title font from start of paragraph title.SpaceStarting = -4;
Now a frame skip occurs to ensure that the Title paragraph has some room to flow a few paragraph lines right below it.
In the case of small paragraphs such as titles, the two properties are nearly equivalent. But they can be also be used on normal paragraphs that should be attached to upcoming inclusions. In the case of SpaceFollowing on long paragraphs, the frame skip will happen Keep lines before the end of the paragraph.
See also ...
Text Flow Tutorials | Flowing Paragraphs | Paragraph Glossary | SharpLeaf.Style Property | ParagraphStyle.Keep Property | ParagraphStyle.SpaceFollowing Property | ParagraphStyle.SpaceStarting Property