openUri static method

Future<PdfDocument> openUri(
  1. Uri uri, {
  2. PdfPasswordProvider? passwordProvider,
  3. bool firstAttemptByEmptyPassword = true,
  4. PdfDownloadProgressCallback? progressCallback,
  5. PdfDownloadReportCallback? reportCallback,
  6. bool preferRangeAccess = false,
  7. Map<String, String>? headers,
})

Opening the PDF from URI.

For Flutter Web, the implementation uses browser's function and restricted by CORS. For other platforms, it uses pdfDocumentFromUri that uses HTTP's range request to download the file.

passwordProvider is used to provide password for encrypted PDF. See PdfPasswordProvider for more info. firstAttemptByEmptyPassword is used to determine whether the first attempt to open the PDF is by empty password or not. For more info, see PdfPasswordProvider.

progressCallback is called when the download progress is updated (Not supported on Web). reportCallback is called when the download is completed (Not supported on Web). preferRangeAccess to prefer range access to download the PDF (Not supported on Web). headers is used to specify additional HTTP headers especially for authentication/authorization.

Implementation

// ignore: comment_references
/// For other platforms, it uses [pdfDocumentFromUri] that uses HTTP's range request to download the file.
///
/// [passwordProvider] is used to provide password for encrypted PDF. See [PdfPasswordProvider] for more info.
/// [firstAttemptByEmptyPassword] is used to determine whether the first attempt to open the PDF is by empty password
/// or not. For more info, see [PdfPasswordProvider].
///
/// [progressCallback] is called when the download progress is updated (Not supported on Web).
/// [reportCallback] is called when the download is completed (Not supported on Web).
/// [preferRangeAccess] to prefer range access to download the PDF (Not supported on Web).
/// [headers] is used to specify additional HTTP headers especially for authentication/authorization.
static Future<PdfDocument> openUri(
  Uri uri, {
  PdfPasswordProvider? passwordProvider,
  bool firstAttemptByEmptyPassword = true,
  PdfDownloadProgressCallback? progressCallback,
  PdfDownloadReportCallback? reportCallback,
  bool preferRangeAccess = false,
  Map<String, String>? headers,
}) =>
    PdfDocumentFactory.instance.openUri(
      uri,
      passwordProvider: passwordProvider,
      firstAttemptByEmptyPassword: firstAttemptByEmptyPassword,
      progressCallback: progressCallback,
      reportCallback: reportCallback,
      preferRangeAccess: preferRangeAccess,
      headers: headers,
    );