filesaver.js

Saving file on IE11 with FileSaver

混江龙づ霸主 提交于 2019-12-03 21:06:11
问题 I'm using FileSaver library ( https://github.com/eligrey/FileSaver.js) and does not work on IE11, with other browsers I had no problem. The code is this: var file = new File(["content"], "sample.xml", { type: "application/xml;charset=utf-8" }); saveAs(file); I'm getting this error when the first instruction (new) executes: "the object does not accept this action" There's an open issue on git hub, but actually with no solution, I'm looking for a workaround that should work on IE11, like this:

How to download an excel (xlsx) file using Angular 5 HttpClient get method with Node/Express backend?

两盒软妹~` 提交于 2019-12-03 20:49:48
I have an excel file in a directory on my nodejs server - Path to the file is - ./api/uploads/appsecuritydesign/output/appsecdesign.xlsx On click of a button in my Angular 5 component I am just trying to download the file using FileSaver. Below is my Angular component. Here the template code for the button in Angular that will call the saveFile() function once clicked. <a class="btn btn-primary" (click) = "saveFile()">Download</a> Here is the saveFile() function. saveFile(){ console.log("In ToolInput Component: ", this.token); //Okta token console.log("In ToolInput Component: ", this

how to convert byte array to pdf and download

坚强是说给别人听的谎言 提交于 2019-12-02 15:54:33
问题 I am trying to do a simple task of downloading a http response to a pdf. I am generating a pdf file but I am getting an error of "Failed to open PDF". Here is what the response looks like. And here is what I am doing. let blob = new Blob([response.data], { type: 'application/pdf' }) FileSaver.saveAs(blob, 'foo.pdf') 回答1: The string from the response seem to be Base-64 encoded (ref. fiddle). You can decode it using fetch() (or XMLHttpRequest() for older browsers): fetch("data:application/pdf

how to convert byte array to pdf and download

こ雲淡風輕ζ 提交于 2019-12-02 10:11:56
I am trying to do a simple task of downloading a http response to a pdf. I am generating a pdf file but I am getting an error of "Failed to open PDF". Here is what the response looks like. And here is what I am doing. let blob = new Blob([response.data], { type: 'application/pdf' }) FileSaver.saveAs(blob, 'foo.pdf') The string from the response seem to be Base-64 encoded (ref. fiddle). You can decode it using fetch() (or XMLHttpRequest() for older browsers): fetch("data:application/pdf;base64," + response.data) .then(function(resp) {return resp.blob()}) .then(function(blob) { FileSaver.saveAs

save excel file using FileSaver.js

丶灬走出姿态 提交于 2019-12-01 17:15:48
I am trying to export data to excel in angular js 1) User clicks a button 2) Data in $scope.myArray gets saved to excel file. I tried var blob = new Blob($scope.myArray , { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8" }); saveAs(blob, "Report.xls"); }; It prompts to open the excel file. But whenever I try to open it, it says the file format or file extension is not valid. Any Help! Try the following code that will help you to create an excel file for you. var result = ["Item 1", "Item 3"]; const myJsonString = JSON.stringify(result); const blob = new

Saving file on IE11 with FileSaver

点点圈 提交于 2019-11-30 22:44:16
I'm using FileSaver library ( https://github.com/eligrey/FileSaver.js ) and does not work on IE11, with other browsers I had no problem. The code is this: var file = new File(["content"], "sample.xml", { type: "application/xml;charset=utf-8" }); saveAs(file); I'm getting this error when the first instruction (new) executes: "the object does not accept this action" There's an open issue on git hub, but actually with no solution, I'm looking for a workaround that should work on IE11, like this: try { var file = new File([msg.d], "test.xml", { type: "application/xml;charset=utf-8" }); saveAs(file

Use Filesaver js with angular2

流过昼夜 提交于 2019-11-29 10:49:11
i have checked all the post i can find on the use of Filesaver JS with angular, but i still could not wrap my head around a soution. I added this to the map section of my system.config.js 'filesaver': 'node_modules/filesaver/src/Filesaver.js' I added this to the packages section of the system.config.js 'filesaver': {defaultExtension: 'js'} I then imported it in my service.ts this way import { saveAs } from 'filesaver'; Yet i get this error. Can someone help please? Try the following npm install file-saver --save Then add a declarations file to your project like 'declarations.d.ts' and in it

Download large size files with angular file saver

前提是你 提交于 2019-11-28 12:46:37
I have implemented angular file saver into my project with purpose to download files and it works fine for small files, but for files larger then 50mb I see next error and downloading stops after 35-50mb. net::ERR_INCOMPLETE_CHUNKED_ENCODING I have tried to investigate this question in internet and have found that there is a limit 500mb on downloading because obviously cannot be stored so much information in RAM. Unfortunately I didn't find any other quite explanation how to resolve this issue, then I have asked the back-end guy and I've got the answer that everything is fine on his side. So

Angular 2 Best approach to use FileSaver.js

血红的双手。 提交于 2019-11-28 09:48:48
I need to use the FileSaver.js ( https://github.com/eligrey/FileSaver.js/ ) in my Angular2 application. I know I can add it as a script file in main html page and it will work. But I was wondering what would be the best approach in case of an Angular 2 (TypeScript) application so that I can just call window.saveAs to save file. I managed to get it work using this approach (Angular-CLI): npm install file-saver --save npm install @types/file-saver --save After that import Filesaver in component: import * as FileSaver from 'file-saver'; And you can use it like this: let blob = new Blob([document

How to save Chart JS charts as image without black background using blobs and filesaver?

匆匆过客 提交于 2019-11-28 07:47:56
$("#NoBidsChart").get(0).toBlob(function(value) { saveAs(value, "Summary.jpg"); }); Here i am using Chart JS(v2.5.0) for rendering charts. When i try to export the charts using Canvas to Blob converter and filesaver.js, i get the black background. So how do i get the image with customized background color(preferably white)? If you want a customized background color then, you'd have to draw a background with your preferred color, and you can do so, like this ... var backgroundColor = 'white'; Chart.plugins.register({ beforeDraw: function(c) { var ctx = c.chart.ctx; ctx.fillStyle =