I am trying to generate PDF content using XSJS. Following is the code. THe PDF is generating but when I try to ope, it says failed to load the file. When I try it on IE, it says its corrupted. Pl. suggest what I am missing in this code.
try {
//$.response.headers.set("Content-Disposition", "Content-Disposition: attachment; filename=test.pdf");
$.response.headers.set('Content-Disposition', 'attachment; filename ="test.pdf"');
$.response.contentType = "application/pdf";
$.response.setBody('ab naresh test');
$.response.status = $.net.http.OK;
}
catch (e) {
$.response.setBody("Error while downloading : "+e);
$.response.status = 500;
}