1
0
mirror of https://github.com/24eme/signaturepdf.git synced 2023-08-25 09:33:08 +02:00

on sort la fct de download

This commit is contained in:
Gabriel Poma 2023-04-20 15:17:49 +02:00
parent 4f4d3a0583
commit 8d9f49a3e8

View File

@ -119,6 +119,15 @@ const deleteMetadata = function(el) {
input.remove()
}
const DL = function (d,f) {
let a = document.createElement("a"),
u = URL.createObjectURL(d);
a.download = f,
a.href = u,
a.click(),
setTimeout(() => URL.revokeObjectURL(u))
}
const save = async function () {
const PDFDocument = window['PDFLib'].PDFDocument
const PDFHexString = window['PDFLib'].PDFHexString
@ -130,14 +139,6 @@ const save = async function () {
pdf.getInfoDict().set(PDFName.of('fooMetadata'), PDFHexString.fromText("test de métadonéé"))
const newPDF = new Blob([await pdf.save()], {type: "application/pdf"})
DL = function (d,f) {
let a = document.createElement("a"),
u = URL.createObjectURL(d);
a.download = f,
a.href = u,
a.click(),
setTimeout(() => URL.revokeObjectURL(u))
}
DL(newPDF, "a.pdf")
}