3

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.

Aeseir
  • 7,754
  • 10
  • 58
  • 107

1 Answers1

1

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

Mason.Chase
  • 897
  • 1
  • 10
  • 21