/// HasColor #region HasColor /// <summary> /// Indicates whether specified file has color or not. Has to be supported file (ps or pdf) /// </summary> /// <param name="fileName">file name</param> /// <returns>true if has color; otherwise false</returns> public static bool?HasColor(string fileName) { if (String.IsNullOrWhiteSpace(fileName)) { return(null); } try { if (!File.Exists(fileName)) { return(null); } SupportedPrintFormat format = GetFileFormat(fileName); if (format == SupportedPrintFormat.PDF) { return(GhostScriptHelper.HasColor(fileName)); } else if (format == SupportedPrintFormat.PS) { return(PostScriptHelper.HasColor(fileName)); } } catch (Exception ex) { WPFNotifier.Error(ex); } return(null); }
/// GetFileFormat #region GetFileFormat /// <summary> /// /// </summary> /// <param name="fileName"></param> /// <returns></returns> public static SupportedPrintFormat GetFileFormat(string fileName) { if (String.IsNullOrWhiteSpace(fileName)) { return(SupportedPrintFormat.None); } try { if (!File.Exists(fileName)) { return(SupportedPrintFormat.None); } } catch { return(SupportedPrintFormat.None); } if (PDFHelper.IsPDF(fileName)) { return(SupportedPrintFormat.PDF); } if (PostScriptHelper.IsPS(fileName)) { return(SupportedPrintFormat.PS); } return(SupportedPrintFormat.Unknown); }