---
title: "Fill PDF forms from database in C# | Nutrient .NET SDK"
canonical_url: "https://www.nutrient.io/guides/dotnet/forms/fill-form-fields/import-from-database/"
md_url: "https://www.nutrient.io/guides/dotnet/forms/fill-form-fields/import-from-database.md"
last_updated: "2026-11-13T22:27:27.942Z"
description: "Learn how to import XFDF data from databases and fill PDF forms using C#. Step-by-step guide with code examples for .NET integration."
---

# Import XFDF data into PDF forms using C#

An XML Forms Data Format (XFDF) file stores data from forms located in PDF documents. It contains the values of the form fields and can also contain annotations.

[Download sample](https://www.nutrient.io/downloads/samples/gdpicture/import-from-database.zip)

To import the form data from a database, save the XFDF information from the database as a `Stream` object, and then use the [`ImportXFDFDataFromStream` method](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~ImportXFDFDataFromStream.html) with the following required parameters:

- `Stream` — The `Stream` object containing XFDF information.

- `ImportFormFields` — A Boolean value that specifies whether to import the form field data.

- `ImportAnnotations` — A Boolean value that specifies whether to import the annotation data.

The example below imports form field values into a PDF form from a `Stream` object containing XFDF information:

### C#

Register the SDK license before running SDK operations. For setup details, refer to the [getting started with.NET SDK](https://www.nutrient.io/sdk/dotnet/getting-started.md) guide.

```csharp

using GdPicture14;

LicenseManager license = new LicenseManager();
license.RegisterKEY("");

```

```csharp

using GdPicturePDF gdpicturePDF = new GdPicturePDF();
byte[] xfdfData = File.ReadAllBytes(@"input_forms.xfdf");
using MemoryStream xfdfStream = new MemoryStream(xfdfData);
gdpicturePDF.LoadFromFile(@"input_forms.pdf");
gdpicturePDF.ImportXFDFDataFromStream(xfdfStream, true, true);
gdpicturePDF.SaveToFile(@"output.pdf");

```

### VB.NET

Register the SDK license before running SDK operations. For setup details, refer to the [getting started with.NET SDK](https://www.nutrient.io/sdk/dotnet/getting-started.md) guide.

```vb

Imports GdPicture14

Dim license As LicenseManager = New LicenseManager()
license.RegisterKEY("")

```

```vb

Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
    Dim xfdfData As Byte() = System.IO.File.ReadAllBytes("input_forms.xfdf")
    Using xfdfStream As System.IO.MemoryStream = New System.IO.MemoryStream(xfdfData)
        gdpicturePDF.LoadFromFile("input_forms.pdf")
        gdpicturePDF.ImportXFDFDataFromStream(xfdfStream, True, True)
        gdpicturePDF.SaveToFile("output.pdf")
    End Using
End Using

```

#### Used methods

- [`ImportXFDFDataFromStream`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~ImportXFDFDataFromStream.html)

- [`LoadFromFile`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~LoadFromFile.html)

- [`SaveToFile`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~SaveToFile.html)

#### Related topics

- [Load a file](/guides/dotnet/load-a-file.md)

- [Save a file](/guides/dotnet/save-a-file.md)
---

## Related pages

- [C# .NET PDF Form Library](/guides/dotnet/forms/fill-form-fields/add-image.md)
- [C# .NET PDF Form Library](/guides/dotnet/forms/fill-form-fields/attach-file.md)
- [Fill PDF forms using XFDF in C# .NET](/guides/dotnet/forms/fill-form-fields/import-from-xfdf.md)
- [C# .NET PDF form library](/guides/dotnet/forms/fill-form-fields/programmatic.md)

