forked from MapComplete/MapComplete
Download pdf and png possible - pdf doesn't scale well
This commit is contained in:
parent
8cc3f8bede
commit
35bb27d365
4 changed files with 467 additions and 14303 deletions
7
Utils.ts
7
Utils.ts
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue