---
title: "Attach file to PDF on Android | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/android/features/embedded-files/"
md_url: "https://www.nutrient.io/guides/android/features/embedded-files.md"
last_updated: "2026-06-09T10:25:14.336Z"
description: "PDF 1.4 added support for embedded files, allowing objects to be embedded into any PDF — this includes deep nesting (e.g."
---

# Attach files to PDFs on Android

PDF 1.4 added support for embedded files, allowing objects to be embedded into any PDF — this includes deep nesting (e.g. a PDF can contain a PDF which contains a PDF which contains a DOCX file). Via the GoToE action, links that link to embedded files inside a PDF can be created.

Any file or binary file data can be attached to a document.

Nutrient supports two ways of attaching files to a document:

1. A file can be attached to a `FileAnnotation`. The file annotation is represented by a small icon on the page (similar to a note annotation), and it provides access methods to the file.

2. Files can be attached directly to the `PdfDocument`. These files aren’t visible on the document and can be accessed using the `EmbeddedFilesProvider`, which can be retrieved by calling `PdfDocument#getEmbeddedFilesProvider()`.

The `EmbeddedFilesProvider` gives access to all embedded files in a document, independent of whether they’re attached to `FileAnnotation`s or directly to the document.

Nutrient has the ability to create a [`FileAnnotation`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.annotations/-file-annotation/index.html) with embedded files. Take a look at the [file annotations](https://www.nutrient.io/guides/android/annotations/file-annotations.md) guide and `FileAnnotationCreationExample` inside the Catalog app, both of which show how to programmatically create file annotations with embedded files.

See also: [How to embed files using file annotations](https://www.nutrient.io/blog/how-to-embed-files-using-file-annotations/)

## Programmatically creating a file annotation with an embedded file

You can create a file annotation with an embedded file using the URL of any file. Here’s how this looks in code:

```kotlin

// Open `PdfDocument`.
val document = PdfDocumentLoader.openDocument(context, uri)

// Create an embedded file source serving file data from assets.
val embeddedFileSource = EmbeddedFileSource(
    AssetDataProvider("Monthly Budget"),
    "Monthly Budget.xlsx",
    "Monthly Budget"
)

// Create a file annotation instance.
val fileAnnotation = FileAnnotation(
    // Page index 0.
    0,
    // Page rectangle (in PDF coordinates).
    RectF(500f, 250f, 532f, 218f),
    // Use the created embedded file source.
    embeddedFileSource
)
fileAnnotation.iconName = FileAnnotation.GRAPH
fileAnnotation.color = Color.BLUE

// Add the newly created file annotation to the document.
document.annotationProvider.addAnnotationToPage(fileAnnotation)

```

To learn more about how to programmatically create file annotations with embedded files, check out `FileAnnotationCreationExample` on Android inside the [Catalog app](https://www.nutrient.io/guides/android/demo.md).

## PDF portfolio collections

In PDF 1.7, the term “PDF package” was created to describe a PDF document that contains a collection dictionary:

> Beginning with PDF 1.7, PDF documents may specify how a conforming reader’s user interface presents collections of file attachments, where the attachments are related in structure or content. Such a presentation is called a portable collection.

(PDF Reference 1.7, 12.3.5 Collections, Page 370ff)

PDF packages have been improved upon to become PDF Portfolios in Acrobat 9. In most cases, portfolios use a Flash-based interface that was deprecated in PDF 2.0 and is unsupported. [Adobe Flash itself doesn’t work on mobile devices and is deprecated as a whole](https://www.adobe.com/in/products/flashplayer/end-of-life-alternative.html).

Nutrient has no special support for packages and portfolios other than fully exposing the embedded files.
---

## Related pages

- [Add and insert images into PDFs on Android](/guides/android/editor/add-image.md)
- [Add pages to PDF files on Android](/guides/android/editor/add-page.md)
- [Edit text in PDFs on Android](/guides/android/editor/edit-text.md)
- [Customizing PDF editing permissions on Android](/guides/android/editor/document-permissions.md)
- [Merge multiple PDF files on Android](/guides/android/editor/merge-or-combine.md)
- [PDF editor library for Android](/guides/android/features/document-processing.md)
- [Split PDFs on Android](/guides/android/editor/split.md)

