SharpLeaf Reference > SharpLeaf Class SharpLeaf Class
The SharpLeaf class allows the creation of automated reports.
public class SharpLeaf
Example
A SharpLeaf report is generally accomplished in 3 phases:
- Set up the document layout (master pages) and the paragraph styles
- Flow content into frames
- Render report to image
para = "Here's a dummy paragraph of text. As the qualifier suggests its content is "+
"not particularly interesting, but it still reaches its goal of being long "+
"enough to take up more than one line.";
// Define document layouts
page = new PageLayout(PaperSize.Landscape(PaperSize.A5));
page.Add(new Frame("Main",36,36,-36,-36)); // Half-inch margin all around invisible frame
layout = new DocumentLayout(page);
// Define paragraph styles
body = new ParagraphStyle();
body.IndentFirst = 36;
body.SpaceAfter = -1; // Equivalent of one empty line of text after each paragraph
title = body.Clone(); // take a deep copy
title.Font = new FontType("Garamond",15,FontStyle.Bold,Color.Navy);
title.SpaceBefore = -2; // Leave room before a title - unless at top of frame
title.BookmarkLevel = 1; // Automatically bookmark titles at top level
// Start flowing
lf = new SharpLeaf(layout);
lf.AddParagraphs("First title",title);
lf.AddParagraphs(new string[]{para,para},body);
lf.AddParagraphs("Second title",title);
lf.AddParagraphs(new string[]{para,para,para},body);
// Render
lf.SavePdf("myreport.pdf",PdfMode.ShowOutlines);

Have a look at the SharpLeaf tutorials for more examples.
Constructors
SharpLeaf Instance PropertiesArgumentList | Substitution values for {1} ... {99} in TextBlock captions | BulletCount | Next value for numbered lists | CapFont | Font for dropped capitals (default is null for paragraph font) | Decimal | Decimal separator used by Alignment.Decimal (defaults to ‘.’) | Ellipsis | Character that marks text clipping (default is ‘…’ – Unicode 0x2026 – code point 8230 – set to ‘ ‘ to disable) | FrameHeight | Height of current frame (excluding gutter) (ReadOnly) | FrameId | Identifier of the current Frame (ReadOnly) | FrameLeft | Left of current frame (excluding gutter) (ReadOnly) | FrameTop | Top of current frame (excluding gutter) (ReadOnly) | FrameWidth | Width of current frame (excluding gutter) (ReadOnly) | Page | Number of current page, starting at 1 (ReadOnly) | Pages | Number of non-empty pages of the report so far (ReadOnly) | PaperSize | Paper size of current page (ReadOnly) | SoftHyphen | Character marking silent word break (default is Unicode standard ‘’ – U+0x00AD – code point 173) | Style | Working ParagraphStyle | Title | Document title | Version | Get SharpLeaf Version (ReadOnly) | YPosition | Current position on page (ReadOnly) |
SharpLeaf MethodsAddBookmarkReference | Flow text into the current paragraph that will point to a named bookmark (earlier or later set with SetBookmark) | AddHtml | Append text with simple HTML tags to the current paragraph | AddHyperlink | Flow text that will point to a URL | AddParagraphs | Flow new paragraphs of texts into the current frame with optional style | AddRichText | Run a vector of "WordPad" Rich Text Format into frame as new paragraphs. This is specific to "old-style" RTF, and not a general RTF parser. | AddSubscript | Append subscripted text to the current paragraph | AddSuperscript | Append superscripted text to the current paragraph | AddText | Append text to the current paragraph | DrawArrow | Low-level routine to draw an arrow with specified parameters | DrawElement | Draw an arbitrary PageElement on current page | GetCharsets | Return the list of used characters for each used font | GetRemainingHeight | Get remaining height in current frame (from current point to bottom) | GetRemainingWidth | Get available width in current frame | GetTextHeight | Measure the height taken by a paragraph of text, interpreting linebreaks, possibly wrapping inside a specified width. | GetTextWidth | Measure the width taken by a paragraph of text, interpreting newline characters (but not tab characters) | IncludeChart | Add a SharpPlot chart to a report, with optional scaling and wraparound | IncludeImage | Add a picture to a report, with optional scaling and wraparound | IncludeRule | Rule line across frame – unless at the top of a frame | IncludeSpace | Include empty space within text flow | IncludeTable | Flow a table within current frame | NextClear | Move down to the closest spot with a clear margin on the left and/or the right hand side. | NextFrame | Skip flow to a new Frame – may imply a new page. | NextLine | Skip to next line – optionally skipping several | NextPage | Force page throws | NextParagraph | Skip to next paragraph – does nothing if already in a new paragraph | NextTab | Skip a number of tabstops | PopStyle | Restore the ParagraphStyle used before the last PushStyle | PushStyle | Temporarily change the current ParagraphStyle, while pushing previous on to the style stack – undone by PopStyle | RenderDocument | Return completed report as a Document instance | RenderLog | Return report as a readable log | RenderPS | Return report rendered as raw PostScript | RenderPdf | Return report as a PDF stream | RenderSvg | Return report rendered as SVG | RenderXaml | Return report rendered as a XAML Canvas | SaveLog | Save completed report as a readable log file | SavePS | Save report to named file as raw PostScript | SavePdf | Save report to named file as PDF | SaveSvg | Save report to named file as SVG | SaveXaml | Save report to named file as a XAML Canvas | SetArgument | Set a specific argument in the ArgumentList | SetBookmark | Create a bookmark entry for upcoming element (paragraph, text, includes, etc.) | SetBox | Start and stop boxing decorations around text | SetCap | Set up a dropped capital on upcoming paragraph | SetLayout | Change master page layout, closing any started page. | |
See also
SharpLeaf Tutorials | Text Flow Tutorials
RequirementsNamespace: Causeway Assembly: SharpPlot (in sharpplot.dll)
Send comments on this topic © Dyalog Ltd 2016
|