This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/dotnet/annotations/export-instant-json-from-pdf.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Export Instant JSON from a PDF | Nutrient .NET SDK

Instant JSON is Nutrient’s portable, human-readable format for sharing annotations, form fields, form field values, comments, and bookmarks across PDF documents. Use it to move review data between back-end services, store changes outside the PDF, or transfer data between Nutrient SDKs without modifying the underlying file.

This guide shows how to:

  • Load an existing PDF with form fields and add annotations programmatically
  • Export the document’s data as an Instant JSON file
  • Produce both a diff export, which is the default, and a full-state export

Prepare the project

Start by registering the SDK license before you process documents. For setup details, refer to the getting started with .NET SDK guide.

using GdPicture14;
LicenseManager licence = new LicenseManager();
licence.RegisterKEY(""); // Set your license key

Load the PDF document

Begin with the source PDF that already contains content you want to export. In this sample, the file includes a form with three text fields. Load it with LoadFromFile:

using GdPicturePDF pdf = new GdPicturePDF();
pdf.LoadFromFile(@"test_form_fields.pdf");

Add annotations programmatically

Add a few annotations so the export includes more than the pre-existing form fields. Each AddSquareAnnotation and AddStickyNoteAnnotation call mutates the loaded document and the change tracker records it:

pdf.AddSquareAnnotation(72, 144, 200, 60, "Reviewer", "Highlighted region", 2.0f,
PdfAnnotationBorderStyle.PdfAnnotationBorderStyleSolid, 0, 0, 1.0f, 255, 0, 0);
pdf.AddStickyNoteAnnotation(PdfStickyNoteAnnotationIcon.PdfAnnotationIconComment,
72, 220, "Reviewer", "Section question", "Please confirm this section.",
1.0f, false, 255, 255, 0, 0, 0, 0, 0);

Export the diff Instant JSON

By default, ExportInstantJSONDataToFile produces a diff. It includes only items that changed after the document loaded. This matches the Core SDK’s export_document_json behavior and works well when you sync changes back to a server:

GdPictureStatus exportStatus = pdf.ExportInstantJSONDataToFile(@"output.json");
if (exportStatus != GdPictureStatus.OK)
{
Console.Error.WriteLine($"Instant JSON export failed: {exportStatus}");
Environment.Exit(1);
}

The resulting output.json includes the two annotations added above, but it doesn’t repeat the form fields that were already in the source PDF.

Export the full-state Instant JSON

When you need a complete snapshot, pass fullState: true to the stream overload. Use ExportInstantJSONDataToStream for archival, document hand-off, or first-time syncs when the receiver doesn’t yet have the original PDF:

using (FileStream fullStream = new FileStream(@"output_full.json", FileMode.Create, FileAccess.Write))
{
GdPictureStatus fullExportStatus = pdf.ExportInstantJSONDataToStream(fullStream, fullState: true);
if (fullExportStatus != GdPictureStatus.OK)
{
Console.Error.WriteLine($"Full Instant JSON export failed: {fullExportStatus}");
Environment.Exit(1);
}
}

Diff vs. full state — which one to use

Choose the export shape that matches the workflow:

  • Diff export (default) — Stream incremental updates. A server holds the source PDF, the client edits annotations, and the client sends back only what changed.
  • Full export (fullState: true) — Snapshot the document. Use this to archive a complete record of every annotation and form field, or to seed a new document that doesn’t yet share the source.

Both shapes use the same Instant JSON schema, so the same ImportInstantJSONDataFromFile call accepts either one.

Error handling

Always check the GdPictureStatus returned by each export call. Common failure modes include:

  • GdPictureStatus.PdfDocumentMustBeUnencrypted — Instant JSON export refuses to operate on encrypted PDFs
  • GdPictureStatus.GenericError — typically means no PDF is loaded
  • IO errors when the output path can’t be written

For status-handling patterns, refer to the handling errors with .NET SDK guide.

Conclusion

This guide exports a PDF’s annotations and form data as Instant JSON, with both diff and full-state shapes available depending on the workflow. Pair it with the import guide to round-trip changes between documents. For bridge workflows, refer to the Instant JSON and XFDF and Instant JSON and XMP guides.