| ||
SharpPlot Tutorials General Tutorials Chart Samples Style Examples SharpLeaf Tutorials Document Layout Tutorials Text Flow Tutorials Table Tutorials Visual Glossaries SharpPlot Reference SharpPlot Class SharpPlot Properties SharpPlot Methods SharpPlot Structures SharpPlot Enumerations PageMap Class SharpLeaf Reference SharpLeaf Class SharpLeaf Properties SharpLeaf Methods Table Class Table Properties Table Methods SharpLeaf Structures FontType Structure ParagraphStyle Structure BoxStyle Structure SharpLeaf Enumerations DocumentLayout Classes DocumentLayout Class PageLayout Class PageElement Abstract Class Frame : PageElement Class TextBlock : PageElement Class ImageBlock : PageElement Class Box : PageElement Class Rule : PageElement Class Common Reference Document Class VectorMath Class DbUtil Class Download Release Notes Licensing |
Getting Started > Your first Report Your first ReportLet’s build a simple report that will get you started with the SharpLeaf class for reporting. Basic routineAs seen in a first chart tutorial, a typical SharpPlot script iteratively set up parameters and then draws. We can use the same approach to produce a simple report by iteratively adjusting settings then appending text. The following script uses the aplparas variable. lf = new SharpLeaf(); lf.Style.Font.Size=24; // change font size; lf.Style.Alignment=Alignment.Center; // change alignment; lf.AddParagraphs("My Report Title"); // Flow title lf.IncludeSpace(36); // Bump down by half an inch lf.Style.Font.Size=12; // change font size; lf.Style.Alignment=Alignment.Left; // change alignment; lf.Style.SpaceAfter=12; // 12 points of free space after each paragraph; lf.AddParagraphs(aplparas); // Flow text lf.SavePdf("myfirstreport.pdf"); Spicing it upBecause a SharpLeaf script typically has many calls to methods control the flow and append content into the report, settings are generally available as structures, so that a typical SharpLeaf script will have two phases:
Which is pretty similar to modern web design of segregating style (CSS) from content (HTML). Using that mindset, we can make a nicer report with a cleaner script: // Set up paragraph styles title = new ParagraphStyle(); title.Font = new FontType("Garamond",18,FontStyle.Bold,Color.Navy); title.Alignment = Alignment.Center; title.SpaceAfter = 36; // Half an inch of free space below titles title.BookmarkLevel = 1; // Automatically bookmark titles at top level body = new ParagraphStyle(); body.IndentFirst = 36; body.IndentFirstAfterChange = false; // Enforce typographical etiquette // Flow content lf.AddParagraphs("My Report Title",title); // Include an image on the right, scaling it to fit two inches lf.IncludeImage("dyalog.jpg","dyalog.jpg",BoxFlow.Right,144,144); // Start next paragraph with a dropped capital on three lines lf.SetCap(3); lf.AddParagraphs(aplparas,body); // Render report lf.SavePdf("myfirstreport.pdf"); See also ...Getting Started | SharpLeaf Tutorials | SharpPlot in different Languages |