private void AddMissingPathError(ActionResult result, OutputFormat format) { if (_outputFormatHelper.IsPdfFormat(format)) { result.Add(ErrorCode.DefaultViewer_PathIsEmpty_for_Pdf); } switch (format) { case OutputFormat.Jpeg: result.Add(ErrorCode.DefaultViewer_PathIsEmpty_for_Jpeg); break; case OutputFormat.Png: result.Add(ErrorCode.DefaultViewer_PathIsEmpty_for_Png); break; case OutputFormat.Tif: result.Add(ErrorCode.DefaultViewer_PathIsEmpty_for_Tif); break; case OutputFormat.Txt: result.Add(ErrorCode.DefaultViewer_PathIsEmpty_for_Txt); break; default: break; } }
private ActionResult CheckBackgroundPageSettings(ConversionProfile profile, CheckLevel checkLevel) { if (!profile.BackgroundPage.Enabled) return new ActionResult(); if (!_outputFormatHelper.IsPdfFormat(profile.OutputFormat)) return new ActionResult(); if (string.IsNullOrEmpty(profile.BackgroundPage.File)) { _logger.Error("No background file is specified."); return new ActionResult(ErrorCode.Background_NoFileSpecified); } var isJobLevelCheck = checkLevel == CheckLevel.Job; if (!isJobLevelCheck && TokenIdentifier.ContainsTokens(profile.BackgroundPage.File)) return new ActionResult(); if (!profile.BackgroundPage.File.EndsWith(".pdf", StringComparison.InvariantCultureIgnoreCase)) { _logger.Error("The background file \"" + profile.BackgroundPage.File + "\" is no pdf file."); return new ActionResult(ErrorCode.Background_NoPdf); } var pathUtilStatus = _pathUtil.IsValidRootedPathWithResponse(profile.BackgroundPage.File); switch (pathUtilStatus) { case PathUtilStatus.InvalidRootedPath: return new ActionResult(ErrorCode.BackgroundPage_InvalidRootedPath); case PathUtilStatus.PathTooLongEx: return new ActionResult(ErrorCode.BackgroundPage_TooLong); case PathUtilStatus.NotSupportedEx: return new ActionResult(ErrorCode.BackgroundPage_InvalidRootedPath); case PathUtilStatus.ArgumentEx: return new ActionResult(ErrorCode.BackgroundPage_IllegalCharacters); } if (!isJobLevelCheck && profile.BackgroundPage.File.StartsWith(@"\\")) return new ActionResult(); if (!_file.Exists(profile.BackgroundPage.File)) { _logger.Error("The background file \"" + profile.BackgroundPage.File + "\" does not exist."); return new ActionResult(ErrorCode.Background_FileDoesNotExist); } return new ActionResult(); }
/// <summary> /// Open all files in the default viewer /// </summary> /// <param name="job">Job information</param> /// <returns>An ActionResult to determine the success and a list of errors</returns> public ActionResult ProcessJob(Job job) { Logger.Debug("Launched Viewer-Action"); var file = job.OutputFiles.First(); var isPdf = _outputFormatHelper.IsPdfFormat(job.Profile.OutputFormat); if (isPdf && job.Profile.OpenWithPdfArchitect && _pdfArchitectCheck.IsInstalled()) { return(OpenWithArchitect(file)); } return(OpenOutputFile(file)); }
public void IsPdfFormat_ForAllFormats_DoesNotThrowException(OutputFormat outputFormat) { Assert.DoesNotThrow(() => _outputFormatHelper.IsPdfFormat(outputFormat)); }