---
title: "Incremental PDF saving on Android | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/android/faq/growing-pdf-file-size/"
md_url: "https://www.nutrient.io/guides/android/faq/growing-pdf-file-size.md"
last_updated: "2026-05-25T18:42:17.663Z"
description: "Incremental PDF saving on Android | guide for Nutrient Android SDK with detailed instructions and code examples."
---

# Incremental PDF saving on Android

In some cases, the file size of a document will increase with each save. This could be particularly noticeable if the document contains image annotations with large images and is saved often, either explicitly or via any of the available [save triggers](https://www.nutrient.io/../../annotations/annotation-and-bookmark-saving-triggers/).

Incremental saving, which is enabled by default, is the strategy Nutrient uses to make sure saving is as fast as possible: It always appends changes to the end of the document, but it never deletes anything. However, even though this is the fastest way of saving a document, it does come with the cost of incrementing the file size with each save. You can read more about [incremental vs. full saving in PDFs here](https://www.nutrient.io/blog/incremental-and-full-save-in-pdfs/).

In most cases, the file size increase is negligible. However, there might be some cases in which you want to prioritize file size over saving performance. Below you’ll find some strategies to prevent the file size from growing unnecessarily when saving changes to a document.

## Rewriting a document when saving

You can trigger a non-incremental document save, which will rewrite the entire document instead of appending changes at the end.

This can be done by manually saving the document and setting the `incrementalSave` property of [`DocumentSaveOptions`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.document/-document-save-options/index.html) to `false` as follows:

### KOTLIN

```kotlin

val incrementalSave = false
val options = document.defaultDocumentSaveOptions
options.isIncremental = incrementalSave
document.saveIfModified(options)

```

### JAVA

```java

final boolean incrementalSave = false;
final DocumentSaveOptions options = document.getDefaultDocumentSaveOptions();
options.setIncremental(incrementalSave);
document.saveIfModified(options);

```

Keep in mind that rewriting the document does not guarantee that the file size will be the same after saving.

### Optimizing size even further

In addition to disabling incremental saving, you can also set the `rewriteAndOptimizeFileSize` property of [`DocumentSaveOptions`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.document/-document-save-options/index.html) to `true`. This will cause Nutrient to first determine which objects in the PDF are no longer required and then remove them from the final output:

### KOTLIN

```kotlin

val incrementalSave = false
val options = document.defaultDocumentSaveOptions
options.isIncremental = incrementalSave
options.setRewriteAndOptimizeFileSize(true)
document.saveIfModified(options)

```

### JAVA

```java

final boolean incrementalSave = false;
final DocumentSaveOptions options = document.getDefaultDocumentSaveOptions();
options.setIncremental(incrementalSave);
options.setRewriteAndOptimizeFileSize(true);
document.saveIfModified(options);

```

While this leads to smaller file sizes, performing this operation is not free and will increase the time it takes to save documents.

When `rewriteAndOptimizeFileSize` is enabled, incremental saving will automatically be disabled.

Do not rely on file size optimization to get to a target file size. This option does not provide any kind of guarantee that the resulting file will be smaller by a fixed number of bytes.

## Disabling incremental save when using auto-save

The method described above works only when you are [saving manually](https://www.nutrient.io/../../annotations/annotation-and-bookmark-saving-triggers#manual-saving). But it is also possible to disable incremental saving when using auto-save with [`PdfActivity`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-activity/index.html) or [`PdfFragment`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-fragment/index.html).

The simplest method is to disable incremental saving via [`DocumentListener#onDocumentSave()`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.listeners/-document-listener/on-document-save.html):

### KOTLIN

```kotlin

override fun onDocumentSave(document: PdfDocument, saveOptions: DocumentSaveOptions): Boolean {
    saveOptions.isIncremental = false
    return super.onDocumentSave(document, saveOptions)
}

```

### JAVA

```java

@Override
public boolean onDocumentSave(@NonNull PdfDocument document, @NonNull DocumentSaveOptions saveOptions) {
    saveOptions.setIncremental(false);
    return super.onDocumentSave(document, saveOptions);
}

```

Incremental saving can also be prevented by using a custom [`WritableDataProvider`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.document.providers/-writable-data-provider/index.html) with disabled appending:

### KOTLIN

```kotlin

// Return `false` from `supportsAppending()` to prevent incremental saving.
val dataProvider = object: ContentResolverDataProvider(uri) {
    override fun supportsAppending(): Boolean {
        return false
    }
}

// Start the activity.
val intent = PdfActivityIntentBuilder.fromDataProvider(context, dataProvider).configuration(configuration).build()
context.startActivity(intent)

```

### JAVA

```java

// Return `false` from `supportsAppending()` to prevent incremental saving.
DataProvider dataProvider = new ContentResolverDataProvider(uri) {
    @Override
    public boolean supportsAppending() {
        return false;
    }
};

// Start the activity.
Intent intent = PdfActivityIntentBuilder.fromDataProvider(context, dataProvider).configuration(configuration).build();
context.startActivity(intent);

```
---

## Related pages

- [How to save documents as PDFs on Android](/guides/android/save-a-document/save-as.md)
- [Auto saving PDF files on Android](/guides/android/features/document-checkpointing.md)
- [Saving a PDF file on Android](/guides/android/save-a-document.md)
- [Save PDFs to Document Engine on Android](/guides/android/save-a-document/to-document-engine.md)
- [Save PDFs to a custom data provider on Android](/guides/android/save-a-document/to-custom-data-provider.md)
- [Save PDFs to a remote server on Android](/guides/android/save-a-document/to-remote-server.md)
- [Save PDFs to local storage on Android](/guides/android/save-a-document/to-local-storage.md)

