@Styles.Render("https://cdn.syncfusion.com/ej2/17.4.39/material.css")
@Scripts.Render("https://cdn.syncfusion.com/ej2/17.4.39/dist/ej2.min.js") |
public ActionResult ExportFormFields(jsonObjects jsonObject)
{
PdfRenderer pdfviewer = new PdfRenderer();
var jsonData = JsonConverter(jsonObject);
string jsonResult = pdfviewer.ExportFormFields(jsonData);
return Content(String.Empty);
} |
<div style="height:500px;width:100%;">
@Html.EJS().PdfViewer("pdfviewer").ServiceUrl(VirtualPathUtility.ToAbsolute("~/PdfViewer/")).DocumentLoad("docLoad").Render()
</div>
function docLoad() {
var pdfviewer = document.getElementById("pdfviewer").ej2_instances[0];
pdfviewer.importFormFields('F:\\FormFillingDocument.json');
} |
Thanks - so just so I'm clear, once the next release comes out, I can keep my Controller Load() method as is (pasted it below for reference), but then in the document load event on the javascript side, I can make a call to the importFields to fill the fields. Is that correct? |
Yes, We can import the form fields as JSON data after the nuget release on February 5th 2020 as we mentioned in earlier. It is not necessary to the import form fields during the load method use the provided load method code snippet in your previous update after the implementation. If we import the form fields as JSON data in the document load event then the control will render the imported form fields value in client side. So the ajax request was not required to render the imported data.
Note: If the form fields are constructed in server side then we need to send the ajax request to retrieved the form fields value.
| |
Also, is it not possible to fill the fields in the Load() method itself? It would be ideal if we can fill the fields in the Load() itself to avoid extra AJAX call. |
If we import the form fields as JSON data from the client side then the ajax call was not required to render the imported data. However, if you retrieved the form fields from server side then you can import the form fields as JSON to PDF loaded document and load the saved stream to the PDF viewer control as a workaround. We have modified the controller code based on it and share the same in the below,
Note: Kindly use the below name space in your controller.
using Syncfusion.Pdf.Parsing;
Kindly try the provided code snippet and let us know more details if it does not meet your requirement.
|