Import Instant JSON into a PDF
Instant JSON is Nutrient’s portable format for moving annotations, form fields, form field values, comments, and bookmarks between PDF documents. Importing an Instant JSON file applies those objects to an existing PDF. Use it to reattach review markup, sync changes from a back-end service, or move data between Nutrient SDKs.
This guide shows how to:
- Load a base PDF document
- Apply an Instant JSON file containing annotations to that PDF
- Save the modified PDF with the imported objects in place
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 keyLoad the PDF document
Begin with the PDF that will receive the imported objects. The same Instant JSON file can apply to many different PDFs, so the receiving document doesn’t need to know anything about the JSON ahead of time. Load it with LoadFromFile:
using GdPicturePDF pdf = new GdPicturePDF();pdf.LoadFromFile(@"input.pdf");Count existing annotations
Capture the annotation count before you import with GetAnnotationCount so you can verify how many objects the import added:
int annotationCountBefore = pdf.GetAnnotationCount();Import the Instant JSON file
ImportInstantJSONDataFromFile reads an Instant JSON document and writes its annotations, form fields, form field values, bookmarks, and comments into the loaded PDF. The method returns GdPictureStatus, so always check the result before you continue:
GdPictureStatus importStatus = pdf.ImportInstantJSONDataFromFile(@"test_annotations_instant.json");if (importStatus != GdPictureStatus.OK){ Console.Error.WriteLine($"Instant JSON import failed: {importStatus}"); Environment.Exit(1);}The import is additive, so the source PDF’s existing annotations and form fields stay in place. If you need an authoritative replacement, remove the existing objects first.
Confirm the import
Compare the annotation count before and after with GetAnnotationCount to confirm that the import landed:
int annotationCountAfter = pdf.GetAnnotationCount();Console.WriteLine($"Annotations before import: {annotationCountBefore}");Console.WriteLine($"Annotations after import: {annotationCountAfter}");Save the modified PDF
ImportInstantJSONDataFromFile mutates the in-memory PDF only. Call SaveToFile to persist the change:
GdPictureStatus saveStatus = pdf.SaveToFile(@"output.pdf");if (saveStatus != GdPictureStatus.OK){ Console.Error.WriteLine($"Saving PDF failed: {saveStatus}"); Environment.Exit(1);}Error handling
The import path validates the Instant JSON before it applies changes. Common failure cases include:
GdPictureStatus.PdfDocumentMustBeUnencrypted— Instant JSON import refuses to operate on encrypted PDFsGdPictureStatus.FileNotFound— the path you pass toImportInstantJSONDataFromFiledoesn’t existGdPictureStatus.GenericError— malformed Instant JSON or apdfIdmismatch between the JSON and the loaded PDF. Version-mode imports validate this strictly.
For status-handling patterns, refer to the handling errors with .NET SDK guide.
Conclusion
This guide imports an Instant JSON file into a PDF and layers its annotations and form data on top of the existing document. Pair it with the export guide to round-trip changes between systems.