public static async Task <RasterImage> RasterImageFromFile(string file, bool loadAllPages = false, int firstPageNumber = 1, int lastPageNumber = 1) { RasterImage rasterImage = null; using (var codecs = new RasterCodecs()) { codecs.Options.Png.Save.QualityFactor = 10; codecs.Options.RasterizeDocument.Load.Resolution = 300; codecs.Options.Load.Resolution = 300; codecs.Options.Load.AllPages = loadAllPages; using (var inputStream = LeadStream.Factory.OpenFile(file)) { rasterImage = await codecs.LoadAsync(inputStream, 0, CodecsLoadByteOrder.Bgr, firstPageNumber, lastPageNumber); if (rasterImage.ViewPerspective != RasterViewPerspective.TopLeft) { rasterImage.ChangeViewPerspective(RasterViewPerspective.TopLeft); } } } return(rasterImage); }