Convert PDF to Image in C#

The simplest way to convert PDF to image as of 2024 is using PDFtoImage libary like below. This libary works for dotnet 8.0 as well.

example: Read pdf file and save page 1 (index 0) to jpg file.

using PDFtoImage;
using var pdfStream = File.OpenRead(@"Sample.pdf");
Conversion.SaveJpeg("image-fileStream.jpg", pdfStream, 0, options: new(Dpi: 300, Width:1024, Height:null, WithAspectRatio:true));

You can file more detail in https://github.com/sungaila/PDFtoImage, which is MIT license.

Leave a comment

Your email address will not be published. Required fields are marked *