- Home
- Forum
- Angular - EJ 2
- pdfViewer.downloadFileName is being removed on init pdfviewer component
pdfViewer.downloadFileName is being removed on init pdfviewer component
Hi! Im facing a issue with PdfViewer component in angular; i want to set downloadFileName as a property of component but on init component, this value is being removed; i was debugging in ej2-pdfviewer.es.2015.js and the function clear(triggerEvent) is removing downloadFileName property, being null after init.
The way that i found to set the correct name to downloaded file is catch downloadStart and set pdfViewer.downloadFileName again but i think that is not clean perspective:
<ejs-pdfviewer
#pdfViewer
id="pdfViewer"
[serviceUrl]='service'
[documentPath]='document'
[ajaxRequestSettings]='requestSettings'
[height]="'100%'"
style="display: block;"
[locale]="localeString"
[enableToolbar]='data.settings.enableToolbar'
[enableMagnification]='data.settings.enableMagnification'
[enableNavigationToolbar]='data.settings.enableNavigationToolbar'
[enableThumbnail]='data.settings.enableThumbnail'
[isThumbnailViewOpen]='data.settings.isThumbnailViewOpen'
[enableBookmark]='data.settings.enableBookmark'
[enableNavigation]='data.settings.enableNavigation'
[enableHyperlink]='data.settings.enableHyperlink'
[hyperlinkOpenState]='"NewTab"'
[isAnnotationToolbarOpen]='data.settings.isAnnotationToolbarOpen'
[enableAnnotation]='data.settings.enableAnnotation'
[showNotificationDialog]="false"
[toolbarSettings]="{ toolbarItems: data.settings.toolbarItems, annotationToolbarItems: data.settings.annotationToolbarItems, showTooltip: true}"
[enableDownload]='true'
downloadFileName="documentName"
(ajaxRequestFailed)="onAjaxRequestFailed($event)"
(documentLoadFailed)="onDocumentLoadFailed($event)"
(downloadStart)="onDownloadStart($event, pdfViewer)"
(exportFailed)="onExportFailed($event)"
>
</ejs-pdfviewer>
onDownloadStart(evento, pdfViewer) {
console.log(evento);
pdfViewer.downloadFileName = this.documentName;
}
SIGN IN To post a reply.
2 Replies
BE
Benjamin
June 23, 2021 02:54 PM UTC
ah ok, I found the issue, I deactivate change detection strategy of container component of pdfViewer component, and if i change from onPush to default, i can set downloadFileName.
Regards
DM
Dhivyabharathi Mohan
Syncfusion Team
June 24, 2021 11:32 AM UTC
Hi Benjamin,
Thank you for contacting Syncfusion support.
In our PDF Viewer, we can use the downloadFileName property to provide the name for the downloading document. We have shared the Angular PDF Viewer and code snippet for your reference.
Code snippet:
|
<ejs-pdfviewer id="pdfViewer" [serviceUrl]='service' [documentPath]='document'
(downloadStart)="downloadStart($event)" style="height:640px;display:block">
</ejs-pdfviewer>
downloadStart() {
var viewer = (<any>document.getElementById('pdfViewer')).ej2_instances[0];
viewer.downloadFileName = 'syncfusion.pdf';
}
|
API Reference Link:
Kindly try this and revert us, if you want further assistance.
Regards,
Dhivya.
SIGN IN To post a reply.
- 2 Replies
- 2 Participants
-
BE Benjamin
- Jun 23, 2021 02:36 PM UTC
- Jun 24, 2021 11:32 AM UTC