Display pdf byte array as image in ASP.Net

Last Reply one year ago By dharmendr

Posted one year ago


I use the code as shown on http://www.aspsnippets.com/Articles/Display-Byte-Array-as-Image-without-using-Generic-Handler-in-ASPNet.aspx#comments

It works great for .jpg files, but with a .pdf file it won't work. With a .pdf file no image is shown.

Is it possible to use this code for an .pdf file and if yes : how ?

This is my code:

byte[] pdfBytes = File.ReadAllBytes(@"c:\temp\test.pdf");

string pdfBase64 = Convert.ToBase64String(pdfBytes, 0, pdfBytes.Length);

Image1.ImageUrl = Convert.ToString("data:image;base64,") + pdfBase64;

I tried it also with "data:image\pdf and "data:image\bmp  but no result.

Thanks for your answer.



You are viewing reply posted by: dharmendr one year ago.
Posted one year ago
Instead of saying thanks mark the reply or replies(if multiple) that helped as Answer.
I agree, here is the link: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html