SharpLeaf Tutorials > Text Flow Tutorials > Text Inclusions

Text Inclusions

Objects can be included into the text flow so that text wraps nicely around it.

The following script uses the aplparas variable.

   page = new PageLayout(PaperSize.Landscape(PaperSize.A5));
   page.Add(new Frame("MainFrame",36,36,-36,-36));  // Half-inch margin
   layout = new DocumentLayout(page);

   lf = new SharpLeaf(layout);
  // half a line pitch around each paragraph
   lf.Style.SpaceBefore=-0.5;
   lf.Style.SpaceAfter=-0.5;

   heading = "Figures";
   series = new string[]{"Home","Overseas"};
   years = new string[]{"2013","2014","2015"};
   data = new double[][]{new double[]{50.2,56.4,55},new double[]{21,23.7,19.1}};

   tb = new Table();
   tb.SetTitles(1,1);
   tb.AddRowCells(heading);
   tb.AddRowCells(series);
   tb.NextEmptyRow(1);
   tb.AddColumns(years);
   tb.SetCellAlignment(Alignment.Decimal);
   tb.AddColumns(data);

   sp = new SharpPlot(192,144);
   sp.Gutter = 0;
   sp.FrameStyle = FrameStyles.Boxed;
   sp.MarginBottom = 30;
   sp.Heading = heading;
   sp.SetXLabels(years);
   sp.SetKeyText(series);
   sp.DrawBarChart(data);
   sp.DrawKey();

   lf.IncludeImage("dyalog.jpg","dyalog.jpg",BoxFlow.Center,36);
   lf.IncludeSpace(lf.Style.SpaceAfter);
   lf.IncludeRule(1,144);  // Include a 1-point thick, 2-inch wide rule
   lf.AddParagraphs(aplparas[0]);
   lf.IncludeChart(sp,BoxFlow.Right);  // Include chart at real size
   lf.IncludeSpace(36,-3);  // Knock out blank space, 36-point wide on three lines of text
   lf.AddParagraphs(aplparas[1]);
   lf.IncludeTable(tb,BoxFlow.Left,150);  // Include table at 150-point width
   lf.AddParagraphs(aplparas[2]);

Advanced examples of table inclusions can illustrate better the mindset of inclusions.

See also ...

Text Flow Tutorials | SharpLeaf.IncludeChart Method | SharpLeaf.IncludeImage Method | SharpLeaf.IncludeRule Method | SharpLeaf.IncludeSpace Method | SharpLeaf.IncludeTable Method | SharpLeaf.NextClear Method | ParagraphStyle.HorizontalGap Property | BoxFlow Enumeration


Send comments on this topic
© Dyalog Ltd 2021