0

m trying to get byte[] array from DB using a web method now how can i convert and open that byte[] into PDF file using java script call function

my web method

public byte[] openAttach(string id, string code)
    {
        ATTACH_DAL ATT_dal = new ATTACH_DAL();
        ATTACH_Entity ATT_ent = new ATTACH_Entity();

        ATT_ent.PrpATATID = id;
        ATT_ent.PrpATFLNM = code;

        ATT_dal.select_Top_1_ATTACH(ATT_ent, "");

      //here i retrieve the binary data 
        return (byte[])ATT_ent.PrpATSORC;
    }
  • Possible duplicate of [Javascript: Open PDF in new tab from byte array](https://stackoverflow.com/questions/28197179/javascript-open-pdf-in-new-tab-from-byte-array) – Sujit.Warrier Sep 24 '17 at 06:43
  • i tried that success: function (data) { var blob = new Blob([data]); var link = document.createElement('a'); link.href = window.URL.createObjectURL(blob); link.download = "xxx.pdf"; link.click(); }, but it saves the file corrupted – mohamed tammam Sep 24 '17 at 06:54

0 Answers0