How to extract all pages and attachments from PDF to PNG

I am trying to create a process in .NET to convert a PDF and all it's pages + attachments to PNGs. I am evaluating libraries and came across PDFiumSharp but it is not working for me. Here is my code:

string Inputfile = "input.pdf";
string OutputFolder = "Output";

string fileName = Path.GetFileNameWithoutExtension(Inputfile);

using (PdfDocument doc = new PdfDocument(Inputfile))
{
   for (int i = 0; i < doc.Pages.Count; i++)
   {
      var page = doc.Pages[i];
      using (var bitmap = new PDFiumBitmap((int)page.Width, (int)page.Height, false))
      {
         page.Render(bitmap);
         var targetFile = Path.Combine(OutputFolder, fileName + "_" + i + ".png");
         bitmap.Save(targetFile);
      }
   }
}

When I run this code, I get this exception:

screenshot of exception

Does anyone know how to fix this? Also does PDFiumSharp support extracting PDF attachments? If not, does anyone have any other ideas on how to achieve my goal?