> 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/flatten.md).

# Flatten PDF form content in Android

Flatten form fields in a PDF document with ease using PDF interactive forms (AcroForms). Learn about form flattening and how to merge field appearances with page content. Explore Apryse SDK capabiliti

To flatten form fields in a PDF document.

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

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

// flatten only form fields
doc.flattenAnnotations(true);
```

{% endcode %}
{% endtab %}

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

```kotlin
val doc = PDFDoc(filename)

// flatten only form fields
doc.flattenAnnotations(true)
```

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

[PDF interactive forms (AcroForms)](/android/get-started/samples.md#interactiveforms) Full sample code which illustrates some basic PDFNet capabilities related to interactive forms (also known as AcroForms) and annotation flattening.

## About form flattening

Form *flattening* refers to the operation that changes active form fields into a static area that is part of the PDF document, just like other text and images in the document. A completely flattened PDF form does not have any widget annotations or interactive fields.

Using the `Field.Flatten()`or `Page.FlattenField()` methods, it is possible to merge individual field appearances with the page content. Apryse SDK also allows you to flatten all forms in the document in a single function call, with `PDFDoc.FlattenAnnotations(true)`. (The true argument instructs Apryse SDK to only flatten fields; were this method passed false, or no argument, it would flatten all annotations as well as all fields.)

Note that it is not possible to undo the `Field.Flatten()` operation. An alternative approach, one that can be programmatically reversed, would be to set the field as read only using the `Field.SetFlag(Field.e_read_only, true)` method.


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/android/forms/flatten.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
