I am trying to convert an uploaded pdf (byte array) to an image using C# in my ASP.NET MVC application. My app is already using ABCpdf package, but I am having hard time finding code example on how to do such conversion using the package. Can anyone advise? Thanks in advance!
Here is my code. I currently get "Parameter not valid" error on the last statement.
HttpPostedFileBase Attachments;
byte[] PdfAttachmentData;
using (var binaryReader = new BinaryReader(Attachments.InputStream))
{
PdfAttachmentData= binaryReader.ReadBytes(Attachments.ContentLength);
}
using (MemoryStream ms = new MemoryStream(PdfAttachmentData))
{
Image myImage = Image.FromStream(ms);
}
I am unfamiliar with the library, but is
Doc.Rendering.Save(pathToPng)
what you're looking for?Example in the official documentation, in Examples -> PDF Rendering Example.
EDIT :
Solution by OP :