# C1.C1Preview.C1PrintDocument.ConvertUnit

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_C1Preview_C1PrintDocument_ConvertUnit_" data-uid="C1.C1Preview.C1PrintDocument.ConvertUnit*">ConvertUnit Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_C1Preview_C1PrintDocument_ConvertUnit_" data-uid="C1.C1Preview.C1PrintDocument.ConvertUnit*"></a>
<h4 id="C1_C1Preview_C1PrintDocument_ConvertUnit_C1_C1Preview_Unit_C1_C1Preview_UnitTypeEnum_" data-uid="C1.C1Preview.C1PrintDocument.ConvertUnit(C1.C1Preview.Unit,C1.C1Preview.UnitTypeEnum)">ConvertUnit(Unit, UnitTypeEnum)</h4>
<div class="markdown level1 summary"><p>Converts an absolute <a class="xref" href="C1.C1Preview.Unit.html">Unit</a> value to the specified measurement units
(this overload cannot convert to pixels).</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public double ConvertUnit(Unit source, UnitTypeEnum destUnitType)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function ConvertUnit(source As Unit, destUnitType As UnitTypeEnum) As Double</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="C1.C1Preview.Unit.html">Unit</a></td>
      <td><span class="parametername">source</span></td>
      <td><p>The source <a class="xref" href="C1.C1Preview.Unit.html">Unit</a> value to convert (must be an absolute value).</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="C1.C1Preview.UnitTypeEnum.html">UnitTypeEnum</a></td>
      <td><span class="parametername">destUnitType</span></td>
      <td><p>The destination unit type (<a class="xref" href="C1.C1Preview.UnitTypeEnum.html">UnitTypeEnum</a>; cannot be <a class="xref" href="C1.C1Preview.UnitTypeEnum.html#C1_C1Preview_UnitTypeEnum_Pixel">Pixel</a>).</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="https://learn.microsoft.com/dotnet/api/system.double">double</a></td>
      <td><p>A <b>double</b> representing the <code class="paramref">source</code> value expressed in <code class="paramref">destUnitType</code> units.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_C1Preview_C1PrintDocument_ConvertUnit_C1_C1Preview_Unit_C1_C1Preview_UnitTypeEnum__remarks">Remarks</h5>
<div class="markdown level1 remarks"><pre><code>&lt;p&gt;
</code></pre>
<p>The <code class="paramref">source</code> must be an absolute value, such as &quot;5mm&quot;, &quot;1.5in&quot;, &quot;8&quot; and so on.
The source cannot be an expression (such as &quot;prev.width&quot; or &quot;prev.height*2+2mm&quot;).</p>

    <p>
The destination units cannot be <a class="xref" href="C1.C1Preview.UnitTypeEnum.html#C1_C1Preview_UnitTypeEnum_Pixel">Pixel</a>.
To convert to pixels, use <a class="xref" href="C1.C1Preview.C1PrintDocument.ConvertUnit.html#C1_C1Preview_C1PrintDocument_ConvertUnit_C1_C1Preview_Unit_C1_C1Preview_UnitTypeEnum_System_Single_">ConvertUnit(Unit, UnitTypeEnum, float)</a> instead.
</p>
</div>


<a id="C1_C1Preview_C1PrintDocument_ConvertUnit_" data-uid="C1.C1Preview.C1PrintDocument.ConvertUnit*"></a>
<h4 id="C1_C1Preview_C1PrintDocument_ConvertUnit_C1_C1Preview_Unit_C1_C1Preview_UnitTypeEnum_System_Single_" data-uid="C1.C1Preview.C1PrintDocument.ConvertUnit(C1.C1Preview.Unit,C1.C1Preview.UnitTypeEnum,System.Single)">ConvertUnit(Unit, UnitTypeEnum, float)</h4>
<div class="markdown level1 summary"><p>Converts an absolute <a class="xref" href="C1.C1Preview.Unit.html">Unit</a> value to the specified measurement units.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public double ConvertUnit(Unit source, UnitTypeEnum destUnitType, float destDpi)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function ConvertUnit(source As Unit, destUnitType As UnitTypeEnum, destDpi As Single) As Double</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="C1.C1Preview.Unit.html">Unit</a></td>
      <td><span class="parametername">source</span></td>
      <td><p>The source <a class="xref" href="C1.C1Preview.Unit.html">Unit</a> value to convert (must be an absolute value).</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="C1.C1Preview.UnitTypeEnum.html">UnitTypeEnum</a></td>
      <td><span class="parametername">destUnitType</span></td>
      <td><p>The destination unit type (<a class="xref" href="C1.C1Preview.UnitTypeEnum.html">UnitTypeEnum</a>).</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.single">float</a></td>
      <td><span class="parametername">destDpi</span></td>
      <td><p>The destination resolution (DPI; used if the <code class="paramref">destUnitType</code> is <a class="xref" href="C1.C1Preview.UnitTypeEnum.html#C1_C1Preview_UnitTypeEnum_Pixel">Pixel</a>).</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="https://learn.microsoft.com/dotnet/api/system.double">double</a></td>
      <td><p>A <b>double</b> representing the <code class="paramref">source</code> value expressed in <code class="paramref">destUnitType</code> units.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_C1Preview_C1PrintDocument_ConvertUnit_C1_C1Preview_Unit_C1_C1Preview_UnitTypeEnum_System_Single__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>The <code class="paramref">source</code> must be an absolute value, such as &quot;5mm&quot;, &quot;1.5in&quot;, &quot;8&quot; and so on.
The source cannot be an expression (such as &quot;prev.width&quot; or &quot;prev.height*2+2mm&quot;).</p>
</div>
</div>
