title: Creating wrapper objects for PDF library
body: <p>I am having an issue wrapping my head around how to properly wrap a PDF library I am using called <code>IronPDF</code>.</p>
  <p><code>IronPDF</code> has a <code>PdfDocument</code> object.</p>
  <p>My thought was to create a <code>IronPdfDocument</code> object that looks like this:</p>
  <pre><code>public class IronPdfDocument : PdfDocument, IPdfDocument
  {
      public IronPdfDocument(string filePath) : base(filePath) { }
      public IronPdfDocument(Stream stream) : base(stream) { }
      public IronPdfDocument(byte[] data) : base(data) { }
  
      public Stream GetSTream() =&gt; base.Stream;
  }
  </code></pre>
  <p><code>IronPDF</code> also has a Rendering object that is called <code>HtmlToPdf</code> and my thougth was to create an <code>IronPdfRenderer</code> that looks like this:</p>
  <pre><code>public class IronPdfRenderer : HtmlToPdf, IPdfRenderer
  {
      public IronPdfRenderer() : base() { }
  
      public IPdfDocument RenderHtmlAsPdf(string html) 
          =&gt; (IronPdfDocument)base.RenderHtmlAsPdf(html);
  }
  </code></pre>
  <p>Then utilizing the interface objects in code like so:</p>
  <pre><code>public IPdfDocument Execute()
  {
      IPdfRenderer renderer = new IronPdfRenderer();
      return renderer.RenderHtmlAsPdf(myHtmlString);
  }
  </code></pre>
  <p>However, I am getting an error in my <code>IronPdfRenderer</code> object when calling <code>RenderHtmlAsPdf</code> trying to convert <code>IronPDF</code>'s <code>PdfDocument</code> to my wrapped object of <code>IronPdfDocument</code>.</p>
  <p>I understand that at face value a <code>PdfDocument</code> may not be able to be casted to my <code>IronPdfDocument</code>, but I would like to create a more generic structure in my code that would help future proof my business logic as different Pdf Libraries can come and go. I was wondering if anyone could provide any help/insight into what I am doing wrong here?</p>
  <p>Here is the error for anyone interested:</p>
  <pre><code>Unable to cast object of type 'IronPdf.PdfDocument' to type 'MyNamespace.Merge.IronPdfDocument'.
  </code></pre>