/// 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); }
/// HasColor #region HasColor /// <summary> /// Checks whether the postscript file has color inside /// </summary> /// <param name="psFileName">file to be inspected</param> /// <returns>true if colored; otherwise false</returns> public static bool?HasColor(string psFileName) { if (string.IsNullOrWhiteSpace(psFileName)) { return(null); } LogHelper.LogDebug(); try { if (!File.Exists(psFileName)) { return(null); } string pdfTMPFileName = Path.GetTempFileName() + ".pdf"; // and convert PS file to PDF GhostScriptHelper.ConvertPStoPDF(psFileName, pdfTMPFileName); // find out do PDF has color or not? bool hasColor = GhostScriptHelper.HasColor(pdfTMPFileName); try { File.Delete(pdfTMPFileName); } catch (Exception ex) { LogHelper.Log(ex); } return(hasColor); } catch (Exception ex) { WPFNotifier.DebugError(ex); return(null); } }
public static bool HasColor(string fileName) { LogHelper.LogDebug(fileName); return(GhostScriptHelper.HasColor(fileName)); }