fromFile static method
Load a PDF File from a given File
File file
, file to be loaded
Implementation
static Future<PDFDocument> fromFile(dynamic file) async {
if (kIsWeb) {
file as List<int>;
return fromFileWeb(file);
} else {
file as File;
final document = PDFDocument();
document.filePathPublic = file.path;
try {
final pageCount = await _channel
.invokeMethod('getNumberOfPages', {'filePath': file.path});
document.count = document.count = int.parse(pageCount as String);
} catch (e) {
throw Exception('Error reading PDF!');
}
return document;
}
}