BoldSign®Effortlessly integrate e-signatures into your app with the BoldSign® API. Create a sandbox account!
Hello,
I recently upgraded from EJ to EJ2 pdfviewer and have discovered that data is not flooding to a form that was before. Here is how the data flood the form in the old version (screenshot 1):
Here is how the data is flooding in the updated version (screenshot 2):
As you can see, the description fields are missing some data. What I have found, is that the Category type for the form field is causing the problem. For the highlighted field in screenshot 3 (attached in zip file), if I modify the Category from 'Number' to 'None', the information floods the form. The data that we attempt to flood this field with is a string. It seems that the older version ignored this type, and would flood the form with whatever data was requested. It would be a very tedious process to go through all of the fields in the forms we use and modify their Category, is there something we can do that will fix this? Can we ignore the Category of the specific form field when setting the data?
Also, I have also discovered that the Line Separator is no longer being honored. If you look at the Limits in screenshot 1 and screenshot 2, the formatting is only being honored in the old version. The limits are displaying without commas.
Thank you for any insight you have.
Best,
Josh
Attachment: Screenshots_8e3b0576.zip
Hi
When loading a document with pre-filled form fields, the values are not displaying correctly. Are you saying that the form fields appear, but the values are not loading properly? Or, if the form fields are present but not filled, you are manually updating them in the backend, but they are still not appearing in the PDF Viewer?
Could you please explain how you are loading the form fields and adding the data to the PDF Viewer? Additionally, let us know how you are changing the form field category from "Number" to "None." Kindly share the list of modules you have injected, along with the relevant code snippet.
If possible, provide a video recording that demonstrates the issue. If the issue is specific to a particular document, we request you to share a copy of the PDF file for further analysis.
Regards,
Priyadharshini
Here are the modules I have injected, as well as how I load the form:
@{ string serviceUrl = VirtualPathUtility.ToAbsolute("~/PDFApiViewer/");}
@(Html.EJS().PdfViewer("pdfviewer")
.ToolbarSettings(new Syncfusion.EJ2.PdfViewer.PdfViewerToolbarSettings
{
ShowTooltip = false,
ToolbarItems = "PageNavigationTool, PrintOption, " +
"SelectionTool, SearchOption, MagnificationTool, UndoRedoTool"
})
.EnableCommentPanel(false)
.FormFieldFocusOut("formfieldModified")
.FormFieldClick("formFieldClicked")
.EnableNavigationToolbar(false)
.EnableAnnotationToolbar(false)
.DocumentLoad("docLoad")
.EnableFormDesigner(false)
.EnableAutoComplete(false)
.Render())
var pdfViewer = document.getElementById('pdfviewer').ej2_instances[0];
pdfViewer.textFieldSettings = {
borderColor: "rgb(0, 0, 0)",
backgroundColor: "rgba(0, 20, 200, 0.2)"
}
pdfViewer.serviceUrl = '@serviceUrl';
pdfViewer.documentPath = '@(Model.FileInformation.Sections[0].Name)_0';
pdfViewer.ajaxRequestInitiate = ajaxRequestInitiate;
pdfViewer.dataBind();
pdfViewer.load(pdfViewer.documentPath, null);
To change the category from "Number" to "None", we are using the Adobe PDF Editor.
The form fields do appear when I load the PDF in the PDF viewer. The issue stems from when I set the data in the back end. I load the form, find the field type, then set the value. Here is the function that takes the field name, the value that is to be set and adds it to the PDF:
/// Set the form field data for the specified field.
public string SetFieldData(string fieldname, string value)
{
var actpdf = pages.FirstOrDefault(p => p.PageIndex == activePage);
var file = actpdf.Pages[actpdf.Pages.Count - 1];
using (var fs = new FileStream(file, FileMode.Open))
{
var pdf = new PdfLoadedDocument(fs);
var pdfForm = pdf.Form;
pdfForm.SetDefaultAppearance(false);
PdfLoadedField theField = null;
for (int i = 0; i < pdfForm.Fields.Count; i++)
{
if (pdfForm.Fields[i].Name.Split('#')[0].ToLower().Equals(fieldname.ToLower()))
{
theField = (PdfLoadedField)pdfForm.Fields[i];
}
}
if (theField != null)
{
// theField = (PdfLoadedField)pdfForm.Fields[actpdf.Fields[actfield.Key]];
//theField = (PdfLoadedField)pdfForm.Fields[actpdf.Fields[fieldname.ToLower()]];
// See if the fields is atext box.
if (theField.GetType() == typeof(PdfLoadedTextBoxField))
{
if (theField.Name.Contains("#"))
{
// Format the value based on formatting info
var fieldInfo = theField.Name.Split('#');
var fieldFormat = fieldInfo[1]; // must be N for number right now.
var fieldDecimals = fieldInfo[2]; // number of decimal places
if (fieldFormat.ToLower().Equals("n"))
{
int fieldVal;
value = value.Split('.')[0];
if (Int32.TryParse(value, out fieldVal))
{
((PdfLoadedTextBoxField)theField).Text = fieldVal.ToString("N0");
}
else
{
((PdfLoadedTextBoxField)theField).Text = value;
}
}
else
{
((PdfLoadedTextBoxField)theField).Text = value;
}
}
else
{
((PdfLoadedTextBoxField)theField).Text = value;
}
}
if (theField.GetType() == typeof(PdfLoadedCheckBoxField))
{
((PdfLoadedCheckBoxField)theField).Checked = (value.ToUpper().Equals("Y"));
}
}
var ms = new MemoryStream();
pdf.Save(ms);
ms.Position = 0;
pdf.Close(true);
var newfs = new FileStream(file, FileMode.Open, FileAccess.Write);
var bytes = ms.ToArray();
newfs.Write(bytes, 0, (int)bytes.Length);
ms.Dispose();
newfs.Dispose();
}
return file;
}
I have attached the empty PDF file (titled 025ACORD316 - empty form) and I have attached the PDF that gets filled in the back end before its displayed in the viewer (populated form), and a video where I discuss this in a bit more detail to hopefully alleviate any questions.
Let me know if you need anything else!
Josh
Attachment: Syncfusion195247_ef0c3cef.zip
Hi
We are checking on the reported scenario and will provide further details by November 25, 2024.
Regards,
Priyadharshini
Hi
Upon analyzing the provided document (025ACORD316 - empty form.pdf), we have confirmed that it contains form fields with additional actions (AA). These actions define the format for preserving text in the text box field. Any input text that does not conform to this format will not be retained in the field.
Currently, our EJ and EJ2 PDF Libraries do not fully support these additional actions, and there are no immediate plans to implement this feature.
However, to resolve this issue and disable the formatting, you can enable the DisableAutoFormat property in the PdfLoadedTextBoxField class.
Please refer to the following snippet code for guidance:
((PdfLoadedTextBoxField)theField).DisableAutoFormat = true; |
Regards,
Priyadharshini