> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/android/forms/export-data.md).

# Extract FDF data from a PDF in Android

Learn how to extract data from PDF to FDF and export FDF as XFDF. Disable annotation auto-save and manage annotation updates with PdfViewCtrlTabFragment2::setSavingEnabled. Explore PDF Form Fill and F

To extract data from PDF to FDF, then export FDF as XFDF

{% tabs %}
{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
PDFDoc doc = new PDFDoc(filename);

// Extract annotations to FDF.
// Optionally use e_both to extract both forms and annotations
FDFDoc doc_fields = doc.fdfExtract(PDFDoc.e_annots_only); //PDFDoc.e_forms_only

// Export annotations from FDF to XFDF.
doc_fields.saveAsXFDF(output_xfdf_filename);

// Optionally write XFDF to a string
String XFDF_string = doc_fields.saveAsXFDF();
```

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
val doc = PDFDoc(filename)

// Extract annotations to FDF.
// Optionally use e_both to extract both forms and annotations
val doc_fields = doc.fdfExtract(PDFDoc.e_annots_only) //PDFDoc.e_forms_only

// Export annotations from FDF to XFDF.
doc_fields.saveAsXFDF(output_xfdf_filename)

// Optionally write XFDF to a string
val XFDF_string = doc_fields.saveAsXFDF()
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% hint style="warning" %}
**Disable annotation auto-save**

Annotation updates by default will automatically save to the PDF. Set [PdfViewCtrlTabFragment2::setSavingEnabled](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/controls/PdfViewCtrlTabFragment2.html#setSavingEnabled\(boolean\)) to false to disable auto-save.
{% endhint %}

[PDF Form Fill and Form Data Extraction](/android/get-started/samples.md#fdf) Full sample code which illustrates basic FDF merge/extract functionality and full support for FDF (Forms Data Format)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.apryse.com/android/forms/export-data.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
