fromFile static method

Future<PDFDoc> fromFile(
  1. File file, {
  2. String password = "",
})

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 {
  var doc = PDFDoc._internal();
  doc._password = password;
  doc._file = file;
  late Map data;
  try {
    data = await _CHANNEL
        .invokeMethod('initDoc', {"path": file.path, "password": password});
  } on Exception catch (e) {
    return Future.error(e);
  }
  doc._pages = List.generate(data["length"], (i) => PDFPage._fromDoc(doc, i));
  doc._info = PDFDocInfo._fromMap(data["info"]);
  return doc;
}