openDocument static method
Future<NutrientDocumentInterface>
openDocument(
- String path, {
- String? password,
- NutrientController? adapter,
Opens a document without a viewer (headless), returning the full document API — annotations, bookmarks, forms, save, export — with no UI.
A document needs an adapter to host it. Pass adapter to use your own
controller (e.g. for typed native access to the opened document); when
omitted, the platform's built-in default adapter hosts it. The returned
document keeps native resources alive — call
NutrientDocumentInterface.close when done.
final doc = await Nutrient.openDocument('report.pdf');
await doc.annotations.importXfdf(xfdf);
await doc.save(outputPath: '/tmp/out.pdf');
await doc.close();
// With native access:
final adapter = createReaderAdapter();
final doc2 = await Nutrient.openDocument('report.pdf', adapter: adapter);
final native = (adapter as ReaderController).nativePdfDocument;
Throws StateError when no adapter is given and the platform has no
default adapter to host the document.
Implementation
static Future<NutrientDocumentInterface> openDocument(
String path, {
String? password,
NutrientController? adapter,
}) =>
_headlessHost(adapter).openDocument(path, password: password);