How to get data from database and make download that content as pdf format in Asp.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sanjaydotnet
    New Member
    • Aug 2014
    • 2

    How to get data from database and make download that content as pdf format in Asp.net

    I have data in varbinary type in database from "Artifact" table like

    ID CONTENT
    1 Some data in varbinary type

    Now i want to get the "Content" column data and should download as PDF format in Users Download folder with name "Report.PDF " file.

    How should i this? I have tried like
    Code:
    public ActionResult DownloadFile(int fileId)
    {
    ResLandEntities reslandEntities = new ResLandEntities();
    
    var content = reslandEntities.ARTIFACT.Where(m => m.ID== fileId).FirstOrDefault();
    byte[] contents = content.CONTENT;
    string text = Encoding.UTF8.GetString(contents);
    
    return File(Server.MapPath("~/download/Report.PDF"), "application/pdf", text );
    }
    But, not getting, can anybody help me
Working...