You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Exporting as [FDF](#3-export-as-fdf), [XFDF](#4-export-as-xfdf), and [JSON](#5-export-as-json) using `exportFormFields()`
15
+
- Exporting as a [JavaScript object](#6-export-as-a-javascript-object) using `exportFormFieldsAsObject()`
18
16
19
-
## Available methods
17
+
## Steps
20
18
21
-
-[exportFormFields](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/index-default#exportformfields)(destination?, format) — Exports data to a file in the specified format.
22
-
-[exportFormFieldsAsObject](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/index-default#exportformfieldsasobject)(format) — Exports data as a JavaScript object for custom handling.
23
-
-[importFormFields](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/index-default#importformfields)(sourceOrObject, format) — Import data back into the PDF.
19
+
### 1. Configure the PDF Viewer
24
20
25
-
## How to export
21
+
Install and import the viewer with required services.
26
22
27
-
Use [exportFormFields()](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/index-default#exportformfields) with an optional destination path and the format type.
Use [exportFormFieldsAsObject()](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/index-default#exportformfieldsasobject) to obtain form data as a JavaScript object for database or API integration.
58
+
Use `FormFieldDataFormat.Json` to export form data as a JSON file.
Use `exportFormFieldsAsObject(format)` to get data for API calls or storing in a database.
67
+
68
+
{% highlight ts %}
69
+
const data = await viewerRef.current?.exportFormFieldsAsObject();
70
+
{% endhighlight %}
71
+
72
+
## Complete example
73
+
74
+
The example below provides a single page with buttons to export in all supported formats. It uses the same imports shown above and is ready to run in a typical React app.
[View Sample on GitHub](https://github.com/SyncfusionExamples/react-pdf-viewer-examples)
192
131
193
-
- Save user-entered data to your server without altering the original PDF.
194
-
- Export as JSON for REST API integration.
195
-
- Export as FDF/XFDF for compatibility with other PDF tools.
196
-
- Export as Object to merge with app state or store securely.
197
-
- Automate exports after [validation](../form-validation) using [validateFormFields()](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/index-default#validateformfields)
132
+
## Troubleshooting
198
133
199
-
[View Sample on GitHub](https://github.com/SyncfusionExamples/react-pdf-viewer-examples)
134
+
- Ensure `FormFields` and `FormDesigner` services are injected when using form APIs.
135
+
- Confirm `resourceUrl` points to the matching `ej2-pdfviewer-lib` version.
136
+
- If exports fail in restrictive browsers, check popup/download settings and CORS for hosted endpoints.
137
+
- For server-side persistence, use `exportFormFieldsAsObject()` and send the result to your API.
0 commit comments