Rajesh Kumar

Rajesh Kumar

  • 1.9k
  • 194
  • 17.8k

convert base64 to pdf and display in mvc

Dec 6 2020 9:37 PM
I have base64 data which i am getting from SOAP. I need to convert that base64 code to pdf and display in popupwindow.
 
if i convert base64 normally it will be in multipage tiff. sometimes it will be jpg, png. So i can't predict format. I have used following code which will convert from base64 to original format. but notsure how to display it in pop up box. whenever i clicked the button which will call below function, file will get downlaod into local machine. i don't want to download, need to display.
 
Any suggestion will be appreciated.
 
  1. In C#   
  2.                var byteA =  
  3.                     @"base64string ";  
  4.                 var imageBytes = Convert.FromBase64String(byteA);  
  5.                 return File(imageBytes, "application /pdf");  
  6.   
  7. In MVC  
  8.    
  9. @Html.ActionLink("View Image""PdfPartial")  
 

Answers (4)