Form Field Import and Export Events in ASP.NET Core PDF Viewer
14 Aug 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 class="text-center">
<ejs-pdfviewer id="pdfviewer" style="height:600px" resourceUrl="https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib" documentPath="https://cdn.syncfusion.com/content/pdf/form-filling-document.pdf">
</ejs-pdfviewer>
</div>
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function () {
var pdfviewer = document.getElementById('pdfviewer').ej2_instances[0];
if (!pdfviewer) { console.warn('PDF Viewer not ready'); return; }
pdfviewer.importStart = function (args) {
console.log('Import started', args);
// e.g. show spinner, validate inputs
};
pdfviewer.importSuccess = function (args) {
console.log('Import success', args);
// e.g. hide spinner, show toast
};
pdfviewer.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 class="text-center">
<ejs-pdfviewer id="pdfviewer" style="height:600px" resourceUrl="https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib" documentPath="https://cdn.syncfusion.com/content/pdf/form-filling-document.pdf">
</ejs-pdfviewer>
</div>
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function () {
var pdfviewer = document.getElementById('pdfviewer').ej2_instances[0];
if (!pdfviewer) { console.warn('PDF Viewer not ready'); return; }
pdfviewer.exportStart = function (args) {
console.log('Export started', args);
// e.g. disable export UI
};
pdfviewer.exportSuccess = function (args) {
console.log('Export success', args);
// e.g. enable UI, provide download link
};
pdfviewer.exportFailed = function (args) {
console.error('Export failed', args);
// e.g. re-enable UI, notify user
};
});
</script>Key Notes
- For each import or export operation, the Start event fires first, followed by either Success or Failed (mutually exclusive).