# GrapeCity.Documents.Text.TextLayout.SplitRef

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="GrapeCity_Documents_Text_TextLayout_SplitRef_" data-uid="GrapeCity.Documents.Text.TextLayout.SplitRef*">SplitRef Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="GrapeCity_Documents_Text_TextLayout_SplitRef_" data-uid="GrapeCity.Documents.Text.TextLayout.SplitRef*"></a>
<h4 id="GrapeCity_Documents_Text_TextLayout_SplitRef_GrapeCity_Documents_Text_TextSplitOptions_GrapeCity_Documents_Text_TextLayout__" data-uid="GrapeCity.Documents.Text.TextLayout.SplitRef(GrapeCity.Documents.Text.TextSplitOptions,GrapeCity.Documents.Text.TextLayout@)">SplitRef(TextSplitOptions, ref TextLayout)</h4>
<div class="markdown level1 summary"><p>Fits all or the first portion of the current text layout into the current layout bounds.
If the whole text did not fit into the bounds, the rest is moved into the <a class="xref" href="GrapeCity.Documents.Text.TextLayout.html">TextLayout</a>
instance specified by the  reference parameter <code class="paramref">rest</code>.
If it is null, a new <a class="xref" href="GrapeCity.Documents.Text.TextLayout.html">TextLayout</a> instance is created.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public SplitResult SplitRef(TextSplitOptions splitOptions, ref TextLayout rest)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function SplitRef(splitOptions As TextSplitOptions, ByRef rest As TextLayout) As SplitResult</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="GrapeCity.Documents.Text.TextSplitOptions.html">TextSplitOptions</a></td>
      <td><span class="parametername">splitOptions</span></td>
      <td><p>Options controlling how text is split.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="GrapeCity.Documents.Text.TextLayout.html">TextLayout</a></td>
      <td><span class="parametername">rest</span></td>
      <td><p>Recipient for the text that did not fit in the current bounds.
If null, a new instance will be created and assigned to this parameter.
If non-null, that <a class="xref" href="GrapeCity.Documents.Text.TextLayout.html">TextLayout</a> instance will be filled with the text that did not fit.
When rendering large blocks of text, this improves performance by avoiding
the need to initialize a new instance of a <a class="xref" href="GrapeCity.Documents.Text.TextLayout.html">TextLayout</a> for each split.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="GrapeCity.Documents.Text.SplitResult.html">SplitResult</a></td>
      <td><p>A value indicating the result of splitting the current text layout.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="GrapeCity_Documents_Text_TextLayout_SplitRef_GrapeCity_Documents_Text_TextSplitOptions_GrapeCity_Documents_Text_TextLayout___remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>Because initializing a new instance of the <a class="xref" href="GrapeCity.Documents.Text.TextLayout.html">TextLayout</a> class takes a relatively long time,
reusing an existing instance can improve performance when rendering large amounts of text.
This is why this method exists, and may be preferred over the <a class="xref" href="GrapeCity.Documents.Text.TextLayout.Split.html#GrapeCity_Documents_Text_TextLayout_Split_GrapeCity_Documents_Text_TextSplitOptions_GrapeCity_Documents_Text_TextLayout__">Split(TextSplitOptions, out TextLayout)</a> method.
The typical use of this method would be:</p>
<pre><code class="lang-csharp">GcPdfDocument doc = new GcPdfDocument();
// ...
TextLayout tl = new TextLayout();
// set up the text layout, add text to it...
TextSplitOptions to = new TextSplitOptions();
// set up text split options...
TextLayout rest = null;
// a loop rendering a long text layout: 
while (true)
{
  var splitResult = tl.SplitRef(to, ref rest);
  doc.Pages.Add().Graphics.DrawTextLayout(tl, PointF.Empty);
  if (splitResult != SplitResult.Split)
    break;
  var temp = tl;
  tl = rest; // move on to the next portion of the text
  rest = temp; // avoid re-initializing a new text layout, by re-using the old one
}</code></pre>
<p>Note that in this code, the ONLY point of swapping 'rest' and 'tl' is to provide an
existing instance of a TextLayout class to the next SplitRef call so that a new instance
does not need to be initialized. No actual data from the old text layout is (re)used,
so functionally the last three lines can be replaced with 'tl = rest; rest = null;'
assignments.</p>
</div>
<h5 id="GrapeCity_Documents_Text_TextLayout_SplitRef_GrapeCity_Documents_Text_TextSplitOptions_GrapeCity_Documents_Text_TextLayout___seealso">See Also</h5>
<div class="seealso">
    <div><a class="xref" href="GrapeCity.Documents.Text.TextLayout.Split.html#GrapeCity_Documents_Text_TextLayout_Split_GrapeCity_Documents_Text_TextSplitOptions_GrapeCity_Documents_Text_TextLayout__">Split</a>(<a class="xref" href="GrapeCity.Documents.Text.TextSplitOptions.html">TextSplitOptions</a>, out <a class="xref" href="GrapeCity.Documents.Text.TextLayout.html">TextLayout</a>)</div>
    <div><a class="xref" href="GrapeCity.Documents.Text.TextLayout.SplitAndBalance.html#GrapeCity_Documents_Text_TextLayout_SplitAndBalance_GrapeCity_Documents_Text_PageSplitArea___GrapeCity_Documents_Text_TextSplitOptions_GrapeCity_Documents_Text_TextLayout__">SplitAndBalance</a>(<a class="xref" href="GrapeCity.Documents.Text.PageSplitArea.html">PageSplitArea</a>[], <a class="xref" href="GrapeCity.Documents.Text.TextSplitOptions.html">TextSplitOptions</a>, out <a class="xref" href="GrapeCity.Documents.Text.TextLayout.html">TextLayout</a>)</div>
    <div><a class="xref" href="GrapeCity.Documents.Text.TextLayout.SplitAndBalanceRef.html#GrapeCity_Documents_Text_TextLayout_SplitAndBalanceRef_GrapeCity_Documents_Text_PageSplitArea___GrapeCity_Documents_Text_TextSplitOptions_GrapeCity_Documents_Text_TextLayout__">SplitAndBalanceRef</a>(<a class="xref" href="GrapeCity.Documents.Text.PageSplitArea.html">PageSplitArea</a>[], <a class="xref" href="GrapeCity.Documents.Text.TextSplitOptions.html">TextSplitOptions</a>, ref <a class="xref" href="GrapeCity.Documents.Text.TextLayout.html">TextLayout</a>)</div>
</div>
</div>
