Hi
I am using EJ1 Web Forms latest version of PDF Viewer in my application.I am creating a PDF Form with help of syncfusion pdf dll and then loading this form pdf in pdf viewer.
My requirement is after the client fills the PDF form and downloads it from PDF Viewer,before downloading I want to validate that all the fields have been filled or not.
Please advise.
Thanks
|
$("#viewer").ejPdfViewer({ enableRequiredFormFieldValidation:true, validateRequiredFormField:"validateRequiredFormField" });
function validateRequiredFormField(args) {
console.log(args);
}
|
Hi
The answer you shared is the exact requirement of mine but I am using Asp.net Web Forms PDF viewer and I tried implementing your answer but it’s not working.
Can you please share a sample?
Hi
Thanks for the sample.Just two more queries-:
1.Is there a way where I can get the name or reference of nonFillableFields ,i.e the fields which are not filled in the below function.
var toolbar = pdfviewerElement.firstElementChild.firstElementChild;
var role = $(toolbar).attr("role");
if (role == "toolbar") {
$(toolbar).append($('<div class="tooltip" style="float: right;"><img runat="server" id="MailBtn1" onclick="SaveNdDownload();" style="margin-top: 13px;margin-right: 10px;float:right" src="../Images/SaveContract.png"/><span class="tooltiptext">Save</span></div>'));
}
|
Query |
Details | |
|
1.Is there a way where I can get the name or reference of nonFillableFields ,i.e the fields which are not filled in the below function.
function validateRequiredFormField(args) {
console.log(args);
}
|
You can get the non-fillable field details using the responseData. Please refer to the below code snippet.
Code Snippet:
| |
|
2.Can we call this function from a custom button on pdf viewer toolbar? As given like this-:
var toolbar = pdfviewerElement.firstElementChild.firstElementChild;
var role = $(toolbar).attr("role");
if (role == "toolbar") {
$(toolbar).append($('<div class="tooltip" style="float: right;"><img runat="server" id="MailBtn1" onclick="SaveNdDownload();" style="margin-top: 13px;margin-right: 10px;float:right" src="../Images/SaveContract.png"/><span class="tooltiptext">Save</span></div>'));
}
|
Yes. You can add the custom button in the PDF Viewer toolbar and call the function from the custom button using this code snippet. Please refer to the below link.
|
Hi,
There seems to be some issue. The sample you shared had a form pdf in Data folder with which validation code is working fine.
But when I am creating a new PDF form by following your documentation link as below and then loading that newly created PDF form in PDF Viewer then the validation code is not working.
Creating new PDF form using this link - https://help.syncfusion.com/file-formats/pdf/working-with-forms?_ga=2.220058333.571650149.1640333881-465845218.1639661839
The below function is not hitting and performing its task as it should when I created a new PDF form using the above documentation link.
|
PdfDocument document = new PdfDocument();
//Add a new page to the PDF document.
PdfPage page = document.Pages.Add();
//Create a textbox field and add the properties.
PdfTextBoxField textBoxField = new PdfTextBoxField(page, "FirstName");
textBoxField.Bounds = new RectangleF(0, 0, 100, 20);
textBoxField.Required = true;
textBoxField.ToolTip = "First Name";
//Add the form field to the document.
document.Form.Fields.Add(textBoxField);
document.Save("../../Save.pdf");
|