private async Task <byte[]> GeneratePdfInternal(string htmlText) { byte[] result; await EnsureFilesExisted() .ConfigureAwait(false); var data = Encoding.UTF8.GetBytes(htmlText); var fileName = $"{Guid.NewGuid().ToString().ToLower()}"; var inputFileName = $"{fileName}.html"; var outputFileName = $"{fileName}.pdf"; var fullFilePath = await _fileManager.CreateFile(inputFileName, data) .ConfigureAwait(false); var cmd = $"/c python.exe scripts/weasyprint.exe \"{fullFilePath}\" \"{outputFileName}\" -e utf8"; var workingDir = _fileManager.FolderPath; await _invoker.ExcuteAsync(workingDir, "cmd.exe", cmd) .ConfigureAwait(false); await _fileManager.Delete(fullFilePath) .ConfigureAwait(false); result = await _fileManager.ReadFile(outputFileName) .ConfigureAwait(false); await _fileManager.Delete(outputFileName) .ConfigureAwait(false); return(result); }