generatePdfFromHtmlUri method

Future<String?> generatePdfFromHtmlUri(
  1. Uri htmlUri,
  2. String outPutFile, [
  3. dynamic options
])

Generates a PDF from HTML URI. htmlUri: The URI to the HTML file to be converted to PDF. The URI can be for a local file or a remote file. outPutFile: The path to the output file. Returns the path to the generated PDF file or null if the input is invalid or if the PDF generation fails.

Implementation

Future<String?> generatePdfFromHtmlUri(Uri htmlUri, String outPutFile,
    [dynamic options]) async {
  if (outPutFile.isEmpty || htmlUri.toString().isEmpty) {
    return null;
  }
  try {
    return await _channel
        .invokeMethod('generatePdfFromHtmlUri', <String, dynamic>{
      'htmlUri': htmlUri.toString(),
      'outputPath': outPutFile,
      'options': options ?? {'documentTitle': 'Document'}
    });
  } on PlatformException catch (e) {
    if (kDebugMode) {
      print(e);
    }
    return null;
  }
}