public void LoadDocument(Document document, string filename, bool attemptSingleImageMode, ResolutionDpi viewingResolution)
    {
      try
      {
        IntPtr docPtr = LibPdfium.LoadDocument(filename);

        for(int i = 0; i < LibPdfium.GetPageCount(docPtr); i++)
        {
          IntPtr pagePtr = LibPdfium.LoadPage(docPtr, i);

          double height = LibPdfium.GetPageHeight(pagePtr);
          double width = LibPdfium.GetPageWidth(pagePtr);
          SizeInches pageSize = new SizeInches(width, height);

          Page myPage = new PageFromPdf(filename, i, pageSize, attemptSingleImageMode, viewingResolution);
          document.AddPage(myPage);

          LibPdfium.ClosePage(pagePtr);
        }

        LibPdfium.CloseDocument(docPtr);
      }
      catch(Exception ex)
      {
        string msg = ex.Message;
      }
    }
    public bool LoadFromFile(Document document, string filename, SizeInches size)
    {
      bool validFile;

      try
      {
        System.Drawing.Image image = Imaging.LoadImageFromFile(filename);
        validFile = true;
      }
      catch(Exception ex)
      {
        string msg = ex.Message;
        validFile = false;
      }

      if(validFile)
      {
        Page myPage = new PageFromFile(filename, size);
        document.AddPage(myPage);
      }

      return validFile;
    }