public void PrintDocment() { String error_str; this.Wait(); #if true bool Success = false; #if true Success = printerOnLocal.PrintDocment(); #endif if (Success == false) { #if true /*---本地打印失败-----*/ try { Success = printerOnNet.PrintDocment(); }catch (Exception e) { LogHelper.WriteLog(this.GetType(), e); } #endif } LibCui.DeleteFile(file.mFileFullPath); LibCui.DeleteFile(file.GetPCLprnfullPath()); #endif this.Release(); if (Success == true) { PrintRecord pp = new PrintRecord(); pp.WriteRecord2Disk(file); } }
public String DownloadPCLFile() { StringBuilder FullUrl = new StringBuilder(); FullUrl.Append(GetAppConfig("URL_DOWNLOAD_FILE")); FullUrl.Append("?LoginID=zhangxiaochen&"); FullUrl.Append("Password=123123&"); FullUrl.Append("FileID=" + PclFileID); return(this.HttpDownloadFile(FullUrl.ToString(), file.GetPCLprnfullPath())); }
private bool PrintDoc(FileSendOnNet file) { String FilePath = file.mFileFullPath; int flag = 0; PCLConvertCS.PCLConvert pc = new PCLConvertCS.PCLConvert(); PCLConvertCS.PDFConvert pcpdf = new PCLConvertCS.PDFConvert(); string fileOut = file.GetPCLprnfullPath(); string printer; if (file.GetPrinterName().Equals("")) { printer = PrintLocalPrint.LocalPrinter.DefaultPrinter(); } else { printer = file.GetPrinterName(); } if (FilePath.ToLower().EndsWith("doc") || FilePath.ToLower().EndsWith("docx")) { string result = pc.WordToPCL(readArgs(FilePath), fileOut, printer); if (result == null) { flag = 1; } } if (FilePath.ToLower().EndsWith("pdf")) { string result = pcpdf.ConvertPdf2pcl(readArgs(FilePath), fileOut); if (result == null) { flag = 1; } } if (FilePath.ToLower().EndsWith("jpg") || FilePath.ToLower().EndsWith("jpeg") || FilePath.ToLower().EndsWith("JPEG")) { string result = pc.JPGToPCL(FilePath, fileOut); if (result == null) { flag = 1; } } if (FilePath.ToLower().EndsWith("xlsx") || FilePath.ToLower().EndsWith("xlsm") || FilePath.ToLower().EndsWith("xls")) { #if false string sPath = System.IO.Path.GetTempPath() + System.IO.Path.GetFileName(FilePath).Replace(".", "_") + ".pdf"; Method m = new Method(); if (m.Convert2PDF(FilePath, sPath, Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF)) { string result = pcpdf.ConvertPdf2pcl(readArgs(sPath), fileOut); if (result == null) { flag = 1; } } #else string sPath = System.IO.Path.GetTempPath() + System.IO.Path.GetFileNameWithoutExtension(FilePath) + Guid.NewGuid().ToString() + ".pdf"; Method m = new Method(); if (m.Convert2PDF(FilePath, sPath, Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF)) { #if true string result = pcpdf.ConvertPdf2pcl(readArgs(sPath), fileOut); #else string result = "测试"; #endif if (result == null) { flag = 1; } } #endif } if (flag == 1) { //文件转换成功-发送到打印机 SendPCL2Printer s2p = new SendPCL2Printer(); return(s2p.SendFile2Printer(fileOut, printer)); } else { Debug.Assert(false); //文件转换失败 return(false); } }
private bool PrintDoc(FileSendOnNet file) { String FilePath = file.mFileFullPath; int flag = 0; PCLConvertCS.PCLConvert pc = new PCLConvertCS.PCLConvert(); PCLConvertCS.PDFConvert pcpdf = new PCLConvertCS.PDFConvert(); string fileOut = file.GetPCLprnfullPath(); string printer; string result = null; if (file.GetPrinterName().Equals("")) { printer = PrintLocal.GetPCLPrinter(); } else { printer = file.GetPrinterName(); } if (FilePath.ToLower().EndsWith("doc") || FilePath.ToLower().EndsWith("docx")) { //Step 1 try{ result = pc.WordToPCL(readArgs(FilePath), fileOut, printer); if (result != null) { LogHelper.WriteLog(this.GetType(), "WORD2PCL 转换失败" + result); result = pc.Word2PDFToPCL(readArgs(FilePath), fileOut, printer); } }catch (Exception e) { LogHelper.WriteLog(this.GetType(), e.Message); } finally { if (result == null) { flag = 1; //转换成功 } } } if (FilePath.ToLower().EndsWith("pdf")) { try { result = pcpdf.ConvertPdf2pcl(readArgs(FilePath), fileOut); if (result == null) { flag = 1; //装换成功 } else { //转换失败 } } catch (Exception e) { LogHelper.WriteLog(this.GetType(), e.Message); } } if (FilePath.ToLower().EndsWith("jpg") || FilePath.ToLower().EndsWith("jpeg") || FilePath.ToLower().EndsWith("JPEG")) { result = pc.JPGToPCL(FilePath, fileOut); if (result == null) { flag = 1; } } if (FilePath.ToLower().EndsWith("xlsx") || FilePath.ToLower().EndsWith("xlsm") || FilePath.ToLower().EndsWith("xls")) { #if false string sPath = System.IO.Path.GetTempPath() + System.IO.Path.GetFileName(FilePath).Replace(".", "_") + ".pdf"; Method m = new Method(); if (m.Convert2PDF(FilePath, sPath, Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF)) { string result = pcpdf.ConvertPdf2pcl(readArgs(sPath), fileOut); if (result == null) { flag = 1; } } #else string sPath = System.IO.Path.GetTempPath() + System.IO.Path.GetFileNameWithoutExtension(FilePath) + Guid.NewGuid().ToString() + ".pdf"; Method m = new Method(); if (m.Convert2PDF(FilePath, sPath, Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF)) { #if true result = pcpdf.ConvertPdf2pcl(readArgs(sPath), fileOut); #else string result = "测试"; #endif if (result == null) { flag = 1; } } #endif } if (flag == 1) { //文件转换成功-发送到打印机 LogHelper.WriteLog(this.GetType(), "文件转换成功"); SendPCL2Printer s2p = new SendPCL2Printer(); return(s2p.SendFile2Printer(fileOut, printer)); } else { LogHelper.WriteLog(this.GetType(), "文件转换:" + result + "&&&" + FilePath); //文件转换失败 return(false); } //return false; }