From 6407613a2e28544b870d2b6c2d4f1eafff5441dc Mon Sep 17 00:00:00 2001 From: essentialjs2 Date: Mon, 12 Jul 2021 09:01:04 +0000 Subject: [PATCH] documentation(EJ2-000): source update from ej2-pdfviewer-angular-docs --- .../create-programmatically.md | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/pdfviewer/pdfviewer/form-designer/create-fillable-PDF-forms/create-programmatically.md b/src/pdfviewer/pdfviewer/form-designer/create-fillable-PDF-forms/create-programmatically.md index 7a2bf38..39abe8f 100644 --- a/src/pdfviewer/pdfviewer/form-designer/create-fillable-PDF-forms/create-programmatically.md +++ b/src/pdfviewer/pdfviewer/form-designer/create-fillable-PDF-forms/create-programmatically.md @@ -181,4 +181,44 @@ You can invoke print action using the following code snippet., We can open the already saved PDF document contains Form Fields in it by clicking the open icon in the toolbar. Refer the below GIF for further reference. -![Alt text](../../../pdfviewer/images/openexistingpdf.gif) \ No newline at end of file +![Alt text](../../../pdfviewer/images/openexistingpdf.gif) + +## Validate form fields + +The form fields in the PDF Document will be validated when the `enableFormFieldsValidation` is set to true and hook the validateFormFields. The validateFormFields will be triggered when the PDF document is downloaded or printed with the non-filled form fields. The non-filled fields will be obtained in the `nonFillableFields` property of the event arguments of validateFormFields. + +Add the following code snippet to validate the form fields, + +```typescript + +import { ViewChild } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; +import { + PdfViewerComponent, LinkAnnotationService, BookmarkViewService, MagnificationService, ThumbnailViewService, + ToolbarService, NavigationService, TextSearchService, TextSelectionService, PrintService, AnnotationService, FormDesignerService, FormFieldsService, LoadEventArgs, TextFieldSettings +} from '@syncfusion/ej2-angular-pdfviewer'; + +@Component({ + selector: 'app-root', + // Specifies the template string for the PDF Viewer component. + template: `
+ +
`, + providers: [LinkAnnotationService, BookmarkViewService, MagnificationService, ThumbnailViewService, ToolbarService, +NavigationService, TextSearchService, TextSelectionService, PrintService, AnnotationService, FormDesignerService, FormFieldsService] +}) +export class AppComponent implements OnInit { + @ViewChild('pdfviewer') + public pdfviewerControl: PdfViewerComponent; + public service: string = 'https://ej2services.syncfusion.com/production/web-services/api/pdfviewer'; + public document: string = 'FormDesigner.pdf'; + + public validateFormFields(e: ValidateFormFieldsArgs): void { + this.e.nonFillableFields; + } + + ngOnInit(): void { + } +} + +``` \ No newline at end of file