Download pdf and png possible - pdf doesn't scale well

This commit is contained in:
LiamSimons 2021-07-22 14:33:49 +02:00
parent 8cc3f8bede
commit 35bb27d365
4 changed files with 467 additions and 14303 deletions

View file

@ -358,9 +358,12 @@ export class Utils {
* @param contents
* @param fileName
*/
public static offerContentsAsDownloadableFile(contents: string, fileName: string = "download.txt") {
public static offerContentsAsDownloadableFile(contents: string | Blob, fileName: string = "download.txt") {
const element = document.createElement("a");
const file = new Blob([contents], {type: 'text/plain'});
let file;
if(typeof(contents) === "string"){
file = new Blob([contents], {type: 'text/plain'});
}else {file = contents;}
element.href = URL.createObjectURL(file);
element.download = fileName;
document.body.appendChild(element); // Required for this to work in FireFox