fromURL static method

Future<PDFDocument> fromURL(
  1. String url, {
  2. Map<String, String>? headers,
  3. CacheManager? cacheManager,
})

Load a PDF File from a given URL. File is saved in cache String url url of the pdf file Map<String,String headers headers to pass for the url CacheManager cacheManager to provide configuration for cache management

Implementation

static Future<PDFDocument> fromURL(String url,
    {Map<String, String>? headers, CacheManager? cacheManager}) async {
  // Download into cache
  final f = await (cacheManager ?? DefaultCacheManager())
      .getSingleFile(url, headers: headers);
  final document = PDFDocument();
  document._filePath = f.path;
  try {
    final pageCount =
        await _channel.invokeMethod('getNumberOfPages', {'filePath': f.path});
    document.count = document.count = int.parse(pageCount as String);
  } catch (e) {
    throw Exception('Error reading PDF!');
  }
  return document;
}