public async Task <TestConversionResult> TestConversion() { const string fileName = "AbbyyTiffTest.tif"; var assemblyLocation = AppDomain.CurrentDomain.BaseDirectory; var img = Resources.AbbyyTiffTest; var path = Path.Combine(assemblyLocation, fileName); var file = new FileInfo(path); if (!file.Exists) { img.Save(path); if (!file.Exists) { return(new TestConversionResult(false, $"Unable to find file {file.FullName}")); } } var targetPath = await renderEngine.ConvertFile(file.FullName, "pdf"); if (targetPath == file.FullName) { return(new TestConversionResult(false, "No conversion done. Abbyy not installed?")); } return(File.Exists(targetPath) ? new TestConversionResult(true, "") : new TestConversionResult(true, $"Could not find File in path: {targetPath}")); }
private async Task <string> ConvertFile(FileInfo file, string[] supportedFileTypesForRendering, JobContext context) { if (!file.Exists) { throw new FileNotFoundException($"Unable to find file {file.FullName}", file.FullName); } if (!supportedFileTypesForRendering.Contains(file.Extension.Replace(".", "").ToLowerInvariant())) { return(file.FullName); } var targetExtension = GetTargetExtension(file); var convertedFile = await renderEngine.ConvertFile(file.FullName, targetExtension, context); return(convertedFile); }