convertFromHtmlFilePath static method

Future<File> convertFromHtmlFilePath({
  1. required String htmlFilePath,
  2. required PrintPdfConfiguration printPdfConfiguration,
})

Creates PDF Document from path to File that contains HTML content Can throw a PlatformException or (unlikely) a MissingPluginException converting html to pdf

Implementation

static Future<File> convertFromHtmlFilePath({
  required String htmlFilePath,
  required PrintPdfConfiguration printPdfConfiguration,
}) async {
  await FileUtils.appendStyleTagToHtmlFile(htmlFilePath);
  final String generatedPdfFilePath = await _convertFromHtmlFilePath(
    htmlFilePath,
    printPdfConfiguration.printSize,
    printPdfConfiguration.printOrientation,
    printPdfConfiguration.linksClickable,
  );

  return FileUtils.copyAndDeleteOriginalFile(
    generatedPdfFilePath,
    printPdfConfiguration.targetDirectory,
    printPdfConfiguration.targetName,
  );
}