We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Get dataFormFields in JSON format?

Hi,

The retrieveFormFields() function returns an object with the properties of each field. Is there a function to retrieve this same information in JSON format so that it can be stored in the database? I have been searching but I can't find if this function exists.

Thank you very much!


9 Replies 1 reply marked as answer

VV Visvesvar Venkatesan Syncfusion Team October 6, 2022 11:07 AM UTC

submit form.png Hi Pere,


You can use our Submit form button in the toolbar menu to export it as JSON. This will export the form field value as Json.


Kindly find the image for the submit button.


Regards,

Visvesvar K V



PA Pere Argelich Romà October 6, 2022 01:46 PM UTC

Hi Visvervar,

I would need to be able to store the JSON in a JavaScript variable programmatically (without user interaction). Is this possible?

Thank you very much!



VV Visvesvar Venkatesan Syncfusion Team October 7, 2022 01:57 PM UTC

Hi Pere,


Thank you for your update.


Kindly find the sample for your requirement below.


Sample - https://stackblitz.com/edit/qnss5r?file=index.html,index.js


Regards,

Visvesvar K V 


Marked as answer

PA Pere Argelich Romà replied to Visvesvar Venkatesan October 7, 2022 04:05 PM UTC

Hi Visvesvar,

Now works fine!! 

Thank you very much!



SK Sinthiya Kalimuthu Syncfusion Team October 10, 2022 08:20 AM UTC

Hi Pere,


Thank you for the update.


Regards,

Sinthiya K



WV Wil van Antwerpen March 12, 2024 12:55 AM UTC

Hi,


The exportData code still works.. great.

But the importData code from the stackBlitz example doesn't appear to work anymore?
On my local workstation it throws a "Webservice is not listening" error (but it is?) and on the stackBlitz workspace it isn't loading the PDF_Succinctly.pdf file for me.. When I try to load something else (eg. the "FormDesigner.pdf" file where I add a textbox form field called  "FirstName") it always tells me " Imported JSON file is not found in the desired location " even when I pass it as a string. eg:

// Render the PDF viewer control
var viewer = new ej.pdfviewer.PdfViewer({
  documentPath: 'FormDesigner.pdf',
  serviceUrl:
    'https://ej2services.syncfusion.com/production/web-services/api/pdfviewer',
});


<snip ... rest of the code from the stackBlitz example>

document.getElementById('id1').addEventListener('click'function () {
  let exportdata = '{"FirstName":"My name"}';
  viewer.importFormFields(exportdata);
  console.log(exportdata);
});

thanks!

--
Wil



SK Sathiyaseelan Kannigaraj Syncfusion Team March 12, 2024 12:12 PM UTC

Hi Pere,

We were able to reproduce the reported issue  "Unable to import Json value into form field” and suspect this to be a defect. We will analyze further on this and update you with more details on March 14th, 2024.


Regards,
Sathiyaseelan K



WV Wil van Antwerpen replied to Sathiyaseelan Kannigaraj March 13, 2024 02:00 PM UTC

Thanks Sathiyaseelan,
Looking forward to hear what you found.

--
Wil



SK Sathiyaseelan Kannigaraj Syncfusion Team March 14, 2024 01:20 PM UTC

Hi Pere Argelich,

It appears that the data value was not properly set at the sample level. We need to update the controller file by setting the provided data into the PDF Viewer server library to resolve this issue.

Furthermore, we need to verify that the provided data is a file or object before setting the values.

Code snippet
:

[AcceptVerbs("Post")]

[HttpPost("ImportFormFields")]

[Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]

[Route("[controller]/ImportFormFields")]

public IActionResult ImportFormFields([FromBody] Dictionary<string, string> jsonObject)

{

    PdfRenderer pdfviewer = new PdfRenderer(_cache);

    var importFormFieldData = GetDocumentPath(jsonObject["data"]);

    if (importFormFieldData == string.Empty)

    {

        var importformFieldDataObject= JsonConvert.DeserializeObject(jsonObject["data"]);

        if (importformFieldDataObject != null)

        {

            jsonObject["data"] = importformFieldDataObject.ToString();

        }

    }

    else

    {

        jsonObject["data"] = importFormFieldData;

    }

           

    object jsonResult = pdfviewer.ImportFormFields(jsonObject);

    return Content(JsonConvert.SerializeObject(jsonResult));

}


Regards,

Sathiyaseelan K


Loader.
Live Chat Icon For mobile
Up arrow icon