I need to convert a pdf file into jpeg using c#. And the solution(library) have to be free.
I have searched a lot of information but seems that I dont get nothing clear.
I already tried itextsharp and pdfbox(but this, the pdf2image is only for java, i think) with no success.
I tried to extract the images from the pdf individually, but I have an error of invalid parameters when i try to extract the images... seems that they have an extrange encoding.
Anyone can recommend me any library to save a pdf into a jpeg? Examples will be very apreciated too.
Thanks!
The library pdfiumviewer might be helpful here. It is also available as nuget.
Try out the following code (change paths to suit your setup).
try
{
using (var document = PdfiumViewer.PdfDocument.Load(@"input.pdf"))
{
var image = document.Render(0, 300, 300, true);
image.Save(@"output.png", ImageFormat.Png);
}
}
catch (Exception ex)
{
// handle exception here;
}
Edit 2: Changed code to show that page index is 0 based as pointed out in comment by S.C. below
Edit 1: Updated solution
Have you tried pdfsharp?