/// 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); }
/// Print #region Print /// <summary> /// Prints file with specified printer and settings /// </summary> /// <param name="fileName">file name</param> /// <param name="printer">printer settings</param> public static void Print(string fileName, string documentName, PrinterSettings printer, PostScriptMetaData data) { if (String.IsNullOrWhiteSpace(fileName)) { return; } if (printer == null) { return; } if (data == null) { return; } try { // check the existence of the file if (!File.Exists(fileName)) { return; } // get file format SupportedPrintFormat format = GetFileFormat(fileName); string newFileName = fileName; // if Postscript file if (format == SupportedPrintFormat.PS) { newFileName = fileName + ".pdf"; // convert to .pdf GhostScriptHelper.ConvertPStoPDF(fileName, newFileName); } // create corresponding print job title PrintJobTitle title = new PrintJobTitle(printer.PrinterName, documentName, Environment.UserName, Environment.MachineName, -1); // skip this title SkipMethod(title); // print document if (PDFHelper.Print(printer, newFileName, documentName, Environment.UserName, Environment.MachineName)) { // add title watcher AddWatcher(title); // log printed data LogPrint(ConfigData.FilePath_PrintLog, documentName, printer, data.NumberOfPages); } } catch (Exception ex) { WPFNotifier.DebugError(ex); } }