# C1.C1Preview.C1PrintDocument.AddAnchor

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_C1Preview_C1PrintDocument_AddAnchor_" data-uid="C1.C1Preview.C1PrintDocument.AddAnchor*">AddAnchor Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_C1Preview_C1PrintDocument_AddAnchor_" data-uid="C1.C1Preview.C1PrintDocument.AddAnchor*"></a>
<h4 id="C1_C1Preview_C1PrintDocument_AddAnchor_System_String_System_String_System_Object_" data-uid="C1.C1Preview.C1PrintDocument.AddAnchor(System.String,System.String,System.Object)">AddAnchor(string, string, object)</h4>
<div class="markdown level1 summary"><p>Adds an anchor (<a class="xref" href="C1.C1Preview.C1Anchor.html">C1Anchor</a> or <a class="xref" href="C1.C1Preview.C1AnchorText.html">C1AnchorText</a>) at the current position in the document.
Can be used only if <a class="xref" href="C1.C1Preview.C1PrintDocument.IsStartEndDocMode.html#C1_C1Preview_C1PrintDocument_IsStartEndDocMode">IsStartEndDocMode</a> is <b>true</b>.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void AddAnchor(string name, string description, object userData)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub AddAnchor(name As String, description As String, userData As Object)</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="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">name</span></td>
      <td><p>A string assigned to the <a class="xref" href="C1.C1Preview.C1Anchor.Name.html#C1_C1Preview_C1Anchor_Name">Name</a> of the anchor.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">description</span></td>
      <td><p>A string assigned to the <a class="xref" href="C1.C1Preview.C1Anchor.Description.html#C1_C1Preview_C1Anchor_Description">Description</a> of the anchor.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></td>
      <td><span class="parametername">userData</span></td>
      <td><p>Arbitrary data assigned to the <a class="xref" href="C1.C1Preview.C1Anchor.UserData.html#C1_C1Preview_C1Anchor_UserData">UserData</a> of the anchor.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_C1Preview_C1PrintDocument_AddAnchor_System_String_System_String_System_Object__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>
This method can only be used if the current document is being created using
the <a class="xref" href="C1.C1Preview.C1PrintDocument.StartDoc.html#C1_C1Preview_C1PrintDocument_StartDoc">StartDoc()</a>/<a class="xref" href="C1.C1Preview.C1PrintDocument.EndDoc.html#C1_C1Preview_C1PrintDocument_EndDoc">EndDoc()</a> methods
(i.e. if <a class="xref" href="C1.C1Preview.C1PrintDocument.IsStartEndDocMode.html#C1_C1Preview_C1PrintDocument_IsStartEndDocMode">IsStartEndDocMode</a> is <b>true</b>).
</p>
The type of anchor that this method creates depends on the current state of the document:
<ul><li>
If an inline paragraph has been started
(e.g. with a call to <a class="xref" href="C1.C1Preview.C1PrintDocument.RenderInline.html#C1_C1Preview_C1PrintDocument_RenderInline_C1_C1Preview_ParagraphObject_System_Object_System_Object_C1_C1Preview_Style_">RenderInline(ParagraphObject, object, object, Style)</a> or <span class="xref">C1.C1Preview.C1PrintDocument.RenderInlineBegin(System.Object,System.Object,C1.C1Preview.Style,System.Boolean)</span>)
and has not been ended (e.g. with a call to <a class="xref" href="C1.C1Preview.C1PrintDocument.RenderInlineEnd.html#C1_C1Preview_C1PrintDocument_RenderInlineEnd">RenderInlineEnd()</a>,
or any of the <b>RenderBlock()</b> or <b>RenderDirect()</b> methods),
this method creates a <a class="xref" href="C1.C1Preview.C1AnchorText.html">C1AnchorText</a> on the current paragraph.
</li><li>
Otherwise (if there's no current inline paragraph),
this method creates a <a class="xref" href="C1.C1Preview.C1Anchor.html">C1Anchor</a> at the current point in the block flow.
</li></ul>
</div>
<h5 id="C1_C1Preview_C1PrintDocument_AddAnchor_System_String_System_String_System_Object__seealso">See Also</h5>
<div class="seealso">
    <div><a class="xref" href="C1.C1Preview.C1PrintDocument.IsInlineStarted.html#C1_C1Preview_C1PrintDocument_IsInlineStarted">IsInlineStarted</a>()</div>
</div>


<a id="C1_C1Preview_C1PrintDocument_AddAnchor_" data-uid="C1.C1Preview.C1PrintDocument.AddAnchor*"></a>
<h4 id="C1_C1Preview_C1PrintDocument_AddAnchor_System_String_System_String_" data-uid="C1.C1Preview.C1PrintDocument.AddAnchor(System.String,System.String)">AddAnchor(string, string)</h4>
<div class="markdown level1 summary"><p>Adds an anchor (<a class="xref" href="C1.C1Preview.C1Anchor.html">C1Anchor</a> or <a class="xref" href="C1.C1Preview.C1AnchorText.html">C1AnchorText</a>) at the current position in the document.
Can be used only if <a class="xref" href="C1.C1Preview.C1PrintDocument.IsStartEndDocMode.html#C1_C1Preview_C1PrintDocument_IsStartEndDocMode">IsStartEndDocMode</a> is <b>true</b>.</p>
<p>
This method is equivalent to <a class="xref" href="C1.C1Preview.C1PrintDocument.AddAnchor.html#C1_C1Preview_C1PrintDocument_AddAnchor_System_String_System_String_System_Object_">AddAnchor(string, string, object)</a>
with the last parameter (user data) specified as <b>null</b> value.
</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void AddAnchor(string name, string description)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub AddAnchor(name As String, description As String)</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="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">name</span></td>
      <td><p>A string assigned to the <a class="xref" href="C1.C1Preview.C1Anchor.Name.html#C1_C1Preview_C1Anchor_Name">Name</a> of the anchor.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">description</span></td>
      <td><p>A string assigned to the <a class="xref" href="C1.C1Preview.C1Anchor.Description.html#C1_C1Preview_C1Anchor_Description">Description</a> of the anchor.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_C1Preview_C1PrintDocument_AddAnchor_System_String_System_String__seealso">See Also</h5>
<div class="seealso">
    <div><a class="xref" href="C1.C1Preview.C1PrintDocument.AddAnchor.html#C1_C1Preview_C1PrintDocument_AddAnchor_System_String_System_String_System_Object_">AddAnchor(string, string, object)</a></div>
</div>


<a id="C1_C1Preview_C1PrintDocument_AddAnchor_" data-uid="C1.C1Preview.C1PrintDocument.AddAnchor*"></a>
<h4 id="C1_C1Preview_C1PrintDocument_AddAnchor_System_String_" data-uid="C1.C1Preview.C1PrintDocument.AddAnchor(System.String)">AddAnchor(string)</h4>
<div class="markdown level1 summary"><p>Adds an anchor (<a class="xref" href="C1.C1Preview.C1Anchor.html">C1Anchor</a> or <a class="xref" href="C1.C1Preview.C1AnchorText.html">C1AnchorText</a>) at the current position in the document.
Can be used only if <a class="xref" href="C1.C1Preview.C1PrintDocument.IsStartEndDocMode.html#C1_C1Preview_C1PrintDocument_IsStartEndDocMode">IsStartEndDocMode</a> is <b>true</b>.</p>
<p>
This method is equivalent to <a class="xref" href="C1.C1Preview.C1PrintDocument.AddAnchor.html#C1_C1Preview_C1PrintDocument_AddAnchor_System_String_System_String_System_Object_">AddAnchor(string, string, object)</a>
with the last two parameters (description and user data) specified as <b>null</b> values.
</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void AddAnchor(string name)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub AddAnchor(name As String)</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="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">name</span></td>
      <td><p>A string assigned to the <a class="xref" href="C1.C1Preview.C1Anchor.Name.html#C1_C1Preview_C1Anchor_Name">Name</a> of the anchor.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_C1Preview_C1PrintDocument_AddAnchor_System_String__seealso">See Also</h5>
<div class="seealso">
    <div><a class="xref" href="C1.C1Preview.C1PrintDocument.AddAnchor.html#C1_C1Preview_C1PrintDocument_AddAnchor_System_String_System_String_System_Object_">AddAnchor(string, string, object)</a></div>
</div>
</div>
