Reputation: 8424
I am trying to figure out if its possible to convert PDF document into a series of images. Currently looking to migrate from ASP.NET 4.6 to ASP.CORE and this is so far the roadbloack to it. I cannot seem to find any working examples for ASP Core of this currently.
Appreciate any help i can get.
Upvotes: 3
Views: 2107
Reputation: 905
You can use Docnet,
Here is an example code from project:
private static byte[] GetModifiedImage(IPageReader pageReader)
{
var rawBytes = pageReader.GetImage();
var width = pageReader.GetPageWidth();
var height = pageReader.GetPageHeight();
var characters = pageReader.GetCharacters();
using (var bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb))
{
bmp.AddBytes(rawBytes);
bmp.DrawRectangles(characters);
using (var stream = new MemoryStream())
{
bmp.Save(stream, ImageFormat.Png);
return stream.ToArray();
}
}
}
Hope it helps Cheers
Upvotes: 1