using Aspose.Pdf;
using Aspose.Pdf.Devices;
using Aspose.Pdf.Facades;
Console.WriteLine(“Hello, World!”);
var filepath1 = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, “Files\111.pdf”);
Document document = new Document(filepath1);
Resolution resolution = new Resolution(300);
JpegDevice jpegDevice = new JpegDevice(resolution);
ConvertPDFtoImage(jpegDevice, document);
Console.ReadLine();
static void ConvertPDFtoImage(ImageDevice imageDevice,
Document pdfDocument)
{
var path = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, “Files\111.jpg”);
for (int pageCount = 1; pageCount <= pdfDocument.Pages.Count; pageCount++)
{
using (FileStream imageStream =
new FileStream($"{path}",
FileMode.Create))
{
// Convert a particular page and save the image to stream
imageDevice.Process(pdfDocument.Pages[pageCount], imageStream);
// Close stream
imageStream.Close();
}
}
}
debug result
System.Exception:“Exception_WasThrown”