convertFromHtmlContent static method

Future<File> convertFromHtmlContent(
  1. String htmlContent,
  2. String targetDirectory,
  3. String targetName
)

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

Implementation

static Future<File> convertFromHtmlContent(String htmlContent, String targetDirectory, String targetName) async {
  final temporaryCreatedHtmlFile = await FileUtils.createFileWithStringContent(htmlContent, "$targetDirectory/$targetName.html");
  final generatedPdfFilePath = await _convertFromHtmlFilePath(temporaryCreatedHtmlFile.path);
  final generatedPdfFile = FileUtils.copyAndDeleteOriginalFile(generatedPdfFilePath, targetDirectory, targetName);
  temporaryCreatedHtmlFile.delete();

  return generatedPdfFile;
}