# C1.WPF.Word.C1WordDocument.DrawElement

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_WPF_Word_C1WordDocument_DrawElement_" data-uid="C1.WPF.Word.C1WordDocument.DrawElement*">DrawElement Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_WPF_Word_C1WordDocument_DrawElement_" data-uid="C1.WPF.Word.C1WordDocument.DrawElement*"></a>
<h4 id="C1_WPF_Word_C1WordDocument_DrawElement_System_Windows_FrameworkElement_System_Windows_Rect_C1_WPF_Word_ContentAlignment_System_Windows_Media_Stretch_" data-uid="C1.WPF.Word.C1WordDocument.DrawElement(System.Windows.FrameworkElement,System.Windows.Rect,C1.WPF.Word.ContentAlignment,System.Windows.Media.Stretch)">DrawElement(FrameworkElement, Rect, ContentAlignment, Stretch)</h4>
<div class="markdown level1 summary"><p>Draws the specified <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.media.imaging.writeablebitmap">WriteableBitmap</a> object at the specified location,
adjusting the image size as specified by the <code class="paramref">align</code> and
<code class="paramref">stretch</code> parameters.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void DrawElement(FrameworkElement e, Rect rc, ContentAlignment align, Stretch stretch)</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.windows.frameworkelement">FrameworkElement</a></td>
      <td><span class="parametername">e</span></td>
      <td><p><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.frameworkelement">FrameworkElement</a> to render into the document.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.rect">Rect</a></td>
      <td><span class="parametername">rc</span></td>
      <td><p>The rectangle structure that specifies the location of the drawn element, in points from the top left corner of the page.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="C1.WPF.Word.ContentAlignment.html">ContentAlignment</a></td>
      <td><span class="parametername">align</span></td>
      <td><p><a class="xref" href="C1.WPF.Word.ContentAlignment.html">ContentAlignment</a> value that specifies how the element should be aligned within the rectangle.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.media.stretch">Stretch</a></td>
      <td><span class="parametername">stretch</span></td>
      <td><p><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.media.stretch">Stretch</a> value that specifies how the element should be sized to fit the rectangle.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_WPF_Word_C1WordDocument_DrawElement_System_Windows_FrameworkElement_System_Windows_Rect_C1_WPF_Word_ContentAlignment_System_Windows_Media_Stretch__remarks">Remarks</h5>
<div class="markdown level1 remarks"><pre><code>&lt;p&gt;This method must be called from the main thread. Calling it from a background thread will
</code></pre>
<p>raise a cross-thread exception when the method tries to access the properties of the
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.frameworkelement">FrameworkElement</a> being rendered.</p>
</div>


<a id="C1_WPF_Word_C1WordDocument_DrawElement_" data-uid="C1.WPF.Word.C1WordDocument.DrawElement*"></a>
<h4 id="C1_WPF_Word_C1WordDocument_DrawElement_System_Windows_FrameworkElement_System_Windows_Rect_System_Windows_Rect_" data-uid="C1.WPF.Word.C1WordDocument.DrawElement(System.Windows.FrameworkElement,System.Windows.Rect,System.Windows.Rect)">DrawElement(FrameworkElement, Rect, Rect)</h4>
<div class="markdown level1 summary"><p>Draws a <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.frameworkelement">FrameworkElement</a> into the document at a specified position.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void DrawElement(FrameworkElement e, Rect rc, Rect rcClip)</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.windows.frameworkelement">FrameworkElement</a></td>
      <td><span class="parametername">e</span></td>
      <td><p><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.frameworkelement">FrameworkElement</a> to render into the document.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.rect">Rect</a></td>
      <td><span class="parametername">rc</span></td>
      <td><p>A rectangle where the element will be rendered.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.rect">Rect</a></td>
      <td><span class="parametername">rcClip</span></td>
      <td><p>A rectangle that defines the clipping bounds.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_WPF_Word_C1WordDocument_DrawElement_System_Windows_FrameworkElement_System_Windows_Rect_System_Windows_Rect__remarks">Remarks</h5>
<div class="markdown level1 remarks"><pre><code>&lt;p&gt;This method uses a &lt;xref href=&quot;System.Windows.Media.VisualTreeHelper&quot; data-throw-if-not-resolved=&quot;false&quot;&gt;&lt;/xref&gt; to render each of the 
</code></pre>
<p>primitives that compose the root element. It does not convert the element
into a bitmap. As a result, the output is smaller and resolution independent;
however, the result is not as faithful as a bitmap rendering. To render an
element as a bitmaps, create a <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.media.imaging.writeablebitmap">WriteableBitmap</a> and pass it to the
<a class="xref" href="C1.WPF.Word.C1WordDocument.DrawImage.html#C1_WPF_Word_C1WordDocument_DrawImage_System_Windows_Media_Imaging_WriteableBitmap_System_Windows_Rect_">DrawImage(WriteableBitmap, Rect)</a> method.</p>
<p>This method must be called from the main thread. Calling it from a background thread will
raise a cross-thread exception when the method tries to access the properties of the
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.frameworkelement">FrameworkElement</a> being rendered.</p>
</div>


<a id="C1_WPF_Word_C1WordDocument_DrawElement_" data-uid="C1.WPF.Word.C1WordDocument.DrawElement*"></a>
<h4 id="C1_WPF_Word_C1WordDocument_DrawElement_System_Windows_FrameworkElement_System_Windows_Rect_" data-uid="C1.WPF.Word.C1WordDocument.DrawElement(System.Windows.FrameworkElement,System.Windows.Rect)">DrawElement(FrameworkElement, Rect)</h4>
<div class="markdown level1 summary"><p>Draws a <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.frameworkelement">FrameworkElement</a> into the document at a specified position.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void DrawElement(FrameworkElement e, Rect rc)</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.windows.frameworkelement">FrameworkElement</a></td>
      <td><span class="parametername">e</span></td>
      <td><p><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.frameworkelement">FrameworkElement</a> to render into the document.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.rect">Rect</a></td>
      <td><span class="parametername">rc</span></td>
      <td><p>A rectangle where the element will be rendered.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_WPF_Word_C1WordDocument_DrawElement_System_Windows_FrameworkElement_System_Windows_Rect__remarks">Remarks</h5>
<div class="markdown level1 remarks"><pre><code>&lt;p&gt;This method uses a &lt;xref href=&quot;System.Windows.Media.VisualTreeHelper&quot; data-throw-if-not-resolved=&quot;false&quot;&gt;&lt;/xref&gt; to render each of the 
</code></pre>
<p>primitives that compose the root element. It does not convert the element
into a bitmap. As a result, the output is smaller and resolution independent;
however, the result is not as faithful as a bitmap rendering. To render an
element as a bitmaps, create a <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.media.imaging.writeablebitmap">WriteableBitmap</a> and pass it to the
<a class="xref" href="C1.WPF.Word.C1WordDocument.DrawImage.html#C1_WPF_Word_C1WordDocument_DrawImage_System_Windows_Media_Imaging_WriteableBitmap_System_Windows_Rect_">DrawImage(WriteableBitmap, Rect)</a> method.</p>
<p>This method must be called from the main thread. Calling it from a background thread will
raise a cross-thread exception when the method tries to access the properties of the
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.frameworkelement">FrameworkElement</a> being rendered.</p>
</div>
</div>
