fromFile static method
Load a PDF File from a given File
File file
, file to be loaded
Automatically clears the on-disk cache of previously rendered PDF previews
unless clearPreviewCache
is set to false
. The option to disable it
comes in handy when working with more than one document at the same time.
If you do this, you are responsible for eventually clearing the cache by hand
by calling PDFDocument.clearPreviewCache.
Implementation
static Future<PDFDocument> fromFile(File file,
{bool clearPreviewCache = true}) async {
PDFDocument document = PDFDocument();
document._filePath = file.path;
try {
var pageCount = await _channel.invokeMethod('getNumberOfPages',
{'filePath': file.path, 'clearCacheDir': clearPreviewCache});
document.count = document.count = int.parse(pageCount);
} catch (e) {
throw Exception('Error reading PDF!');
}
return document;
}