fromFile static method
Creates a PDFDoc object with a File instance.
Optionally, takes a password for encrypted PDF documents.
Implementation
static Future<PDFDoc> fromFile(File file, {String password = ""}) async {
final doc = PDFDoc._internal();
doc._password = password;
doc._file = file;
late Map? data;
try {
data = await _channel
.invokeMethod('initDoc', {"path": file.path, "password": password});
if (data != null) {
doc._pages = List.generate(
data["length"] as int,
(i) => PDFPage._fromDoc(doc, i),
);
doc._info = PDFDocInfo._fromMap(data["info"] as Map);
}
} on Exception catch (e) {
return Future.error(e);
}
return doc;
}