Add PDF download functionality to editor components
Introduced the ability to download PDFs in the `SenderPdfImageEditor` component: - Added `PdfFileName` parameter to specify the file name. - Implemented `CanDownloadPdf` property to enable/disable downloads. - Created `OnDownloadPdfAsync` method to handle download logic via JS interop. Updated `SenderPdfImageEditorToolbar` to support downloads: - Added `CanDownloadPdf` and `DownloadPdf` parameters. - Enabled "Download PDF" button based on `CanDownloadPdf`. - Added `DownloadPdfAsync` method to trigger the download callback. Enhanced `SenderEditorPage` to pass `PdfFileName` to `SenderPdfImageEditor`. Added `downloadDataUrlAsFile` function in `envelope-editor.js` to facilitate file downloads using a temporary `<a>` element. Made minor adjustments for consistency, including adding `ZoomStepPercent` to the toolbar and refining `SetZoomPercent` logic.
This commit is contained in:
@@ -225,5 +225,23 @@ window.envelopeEditor = {
|
||||
|
||||
viewer.addEventListener('touchmove', function () {
|
||||
}, { passive: true });
|
||||
},
|
||||
|
||||
downloadDataUrlAsFile: function (dataUrl, fileName, mimeType) {
|
||||
if (!dataUrl || typeof dataUrl !== 'string') {
|
||||
return;
|
||||
}
|
||||
|
||||
const downloadName = fileName || 'document.pdf';
|
||||
|
||||
const link = document.createElement('a');
|
||||
link.href = dataUrl;
|
||||
link.download = downloadName;
|
||||
link.rel = 'noopener';
|
||||
|
||||
const host = document.body || document.documentElement;
|
||||
host.appendChild(link);
|
||||
link.click();
|
||||
host.removeChild(link);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user