How can I help you?
PDF Form Import and Export Events in MVC
11 Feb 20263 minutes to read
Import/Export events let you track and customize the entire life cycle of form data being imported into or exported from the PDF Viewer.
Use these events to:
- Validate inputs before processing.
- Show progress indicators.
- Log audit trails.
- Block operations based on business rules.
Each event provides detailed context through typed event arguments such as ImportStartEventArgs, ImportSuccessEventArgs, ImportFailureEventArgs, ExportStartEventArgs, ExportSuccessEventArgs, and ExportFailureEventArgs.
Import Events
- importStart — Fires when an import begins.
- importSuccess — Fires when form fields are successfully imported.
- importFailed — Fires if the import fails.
Example: Handle Import Events
<div style="width:100%;height:600px">
@Html.EJS().PdfViewer("pdfviewer").DocumentPath("https://cdn.syncfusion.com/content/pdf/form-filling-document.pdf").Render()
</div>
<script>
document.addEventListener('DOMContentLoaded', function () {
var viewer = document.getElementById('pdfviewer').ej2_instances[0];
viewer.importStart = function (args) {
console.log('Import started', args);
// e.g. show spinner, validate inputs
};
viewer.importSuccess = function (args) {
console.log('Import success', args);
// e.g. hide spinner, show toast
};
viewer.importFailed = function (args) {
console.error('Import failed', args);
// e.g. show error dialog
};
});
</script>Export Events
- exportStart — Fires when an export begins.
- exportSuccess — Fires when form fields are successfully exported.
- exportFailed — Fires if the export fails.
Example: Handle Export Events
<div style="width:100%;height:600px">
@Html.EJS().PdfViewer("pdfviewer").DocumentPath("https://cdn.syncfusion.com/content/pdf/form-filling-document.pdf").Render()
</div>
<script>
document.addEventListener('DOMContentLoaded', function () {
var viewer = document.getElementById('pdfviewer').ej2_instances[0];
viewer.exportStart = function (args) {
console.log('Export started', args);
// e.g. disable export UI
};
viewer.exportSuccess = function (args) {
console.log('Export success', args);
// e.g. enable UI, provide download link
};
viewer.exportFailed = function (args) {
console.error('Export failed', args);
// e.g. re-enable UI, notify user
};
});
</script>Key Notes
- importStart, importSuccess, importFailed cover the full import life cycle.
- exportStart, exportSuccess, exportFailed cover the full export life cycle.