Rasterize to Image using MemoryStream

How do I convert PDF pages to images using memorystream, without touching the file system

PDFs can be loading from MemoryStream:

To export PDF pages as images, first use PdfDocument.ToBitMap() to get an array of .NET bitmaps.

using IronPdf;
using System.Drawing; 

//Example rendering PDF documents to Images or Thumbnails
using var Pdf = PdfDocument.FromFile("Example.pdf");

// or make one using Chrome Renderer
System.Drawing.Bitmap[] pageImages = Pdf.ToBitmap();

foreach (var bitmap in pageImages)
using(MemoryStream memoryStream = new MemoryStream();)
// save to JPEG
bitmap.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg);

// use memoryStream