Beispiel #1
0
        public ImageDocumentPaginator(PrintConfig config)
        {
            _margin = new Thickness(11, 11, 11, 11);

            _pageSize = new Size();

            _bitmapImage = config.DataSource as BitmapImage;

            _imageHeight = _bitmapImage.Height;

            _imageWidth = _bitmapImage.Width;

            _leftTop = new Point(_margin.Left, _margin.Top);

            _pageInfos = new List <PageInfo>();
        }
Beispiel #2
0
        public void TestIndexerWithPredicateRecursively()
        {
            PrintConfig config = new PrintConfig()
            {
                MaxLevelToShow = 1, ShowDeclarative = false
            };
            string testData = File.ReadAllText("Data/XML.xml");
            IEnumerable <IContained> nodes = XElement.Conclude(testData.ToCharArray());
            IElement         root          = nodes.Last() as IElement;
            IList <IElement> levelOneNodes = root[node => node.Level == 1, true].ToList();
            // levelOneNodes.ForEach(node => Console.WriteLine(node.Print(config)));

            IList <IElement> heads = root[node => node.Name == "head", true].ToList();
            var config2            = config with {
                MaxLevelToShow = 100, ShowElements = false
            };
            // heads.ForEach(node => Console.WriteLine(node.Print(config2)));

            IList <IElement> cdatas = root[node => node.GetText(null).Contains("CDATA"), true].ToList();

            cdatas.ForEach(node => Console.WriteLine(node.ToStringWith(config2)));
        }
    }
Beispiel #3
0
        // Fallback to the original GNOME Print API.
        public static void Print(string html)
        {
            string caption = "Monodoc Printing";

            Gnome.PrintJob pj     = new Gnome.PrintJob(PrintConfig.Default());
            PrintDialog    dialog = new PrintDialog(pj, caption, 0);

            Gtk.HTML gtk_html = new Gtk.HTML(html);
            gtk_html.PrintSetMaster(pj);

            Gnome.PrintContext ctx = pj.Context;
            gtk_html.Print(ctx);

            pj.Close();

            // hello user
            int response = dialog.Run();

            if (response == (int)PrintButtons.Cancel)
            {
                dialog.Hide();
                dialog.Destroy();
                return;
            }
            else if (response == (int)PrintButtons.Print)
            {
                pj.Print();
            }
            else if (response == (int)PrintButtons.Preview)
            {
                new PrintJobPreview(pj, caption).Show();
            }

            ctx.Close();
            dialog.Hide();
            dialog.Destroy();
        }
Beispiel #4
0
    public rptAdmision_fecha()
    {
        PrintJob    trabajo   = new PrintJob(PrintConfig.Default());
        PrintDialog dialogo   = new PrintDialog(trabajo, "Prueba", 0);
        int         respuesta = dialogo.Run();

        Console.WriteLine("Respuesta: " + respuesta);

        if (respuesta == (int)PrintButtons.Cancel)
        {
            Console.WriteLine("Impresión cancelada");
            dialogo.Hide();
            dialogo.Dispose();
            return;
        }

        PrintContext ctx = trabajo.Context;

        ComponerPagina(ctx, trabajo);

        trabajo.Close();

        switch (respuesta)
        {
        case (int)PrintButtons.Print:
            trabajo.Print();
            break;

        case (int)PrintButtons.Preview:
            Console.WriteLine("vista previa");
            new PrintJobPreview(trabajo, "Prueba").Show();
            break;
        }

        dialogo.Hide(); dialogo.Dispose();
    }
Beispiel #5
0
        static void Main(string[] args)
        {
            Game.ShowSceneAndAddTurtle();

            Turtle.MoveTo(0, 0);
            Turtle.SetPenWeight(1.5);
            Turtle.SetPenColor(RGBAColors.Cyan.WithAlpha(0x80));
            Turtle.TurnOnPen();
            var n = 5;

            while (n < 200)
            {
                Turtle.MoveInDirection(n);
                Turtle.RotateCounterClockwise(89.5);

                Turtle.ShiftPenColor(10);
                n++;
            }

            // Game.Print(PrintConfig.Create("print-template.html", "Brother HL-5140 series").Set("name", "Johannes Egger"));
            Environment.SetEnvironmentVariable("GET_IT_PRINT_CONFIG", "{ \"templatePath\": \"GetIt.Sample.Print\\\\print-template.html\", \"printerName\": \"Microsoft Print to PDF\" }");
            Game.Print(PrintConfig.CreateFromEnvironment().Set("name", "Johannes Egger"));
            Turtle.Say("Done.");
        }
Beispiel #6
0
 public frmSetting(PrintConfig confg)
 {
     InitializeComponent();
     pconfig = confg;
 }
        public static void SaveAsync(string source, string localfile, string elementname, string width, string height, string dpi)
        {
            var path = Path.GetDirectoryName(localfile);
            //var source = ((Group.HtmlSource)s.Element).Source;
            string html = null;

            if (source.StartsWith("http://") || source.StartsWith("https://") || source.StartsWith("~"))
            {
                /*try {
                 *      var ctx = HttpContext.Current;
                 *      var app = ctx.Request.ApplicationPath;
                 *      var root = ctx.Request.Url.Authority + "/" + app;
                 *      var oldpath = ctx.Request.Url.AbsolutePath;
                 *      path = null;
                 *      if (source.StartsWith(root)) {
                 *              path = source.Substring(root.Length);
                 *      } else if (source.StartsWith("~")) {
                 *              path = source.Substring(1);
                 *      }
                 *      if (path != null) {
                 *              using (var w = new StringWriter()) {
                 *                      ctx.RewritePath(path);
                 *                      ctx.Server.Execute(path, w, false);
                 *                      ctx.RewritePath(oldpath);
                 *                      html = w.ToString();
                 *              }
                 *      }
                 * } catch {
                 * } finally {*/
                /*	if (html == null) {
                 *              var web = new WebClient();
                 *              web.Encoding = Encoding.UTF8;
                 *              html = web.DownloadString(source);
                 *      }
                 * //} */
            }
            var binpath = Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath);

            //AppDomain.CurrentDomain.AppendPrivatePath("Lazy\\Awesomium");
            if (!AssemblyResolverInitialized)
            {
                int resolving = 0;
                AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => {
                    try {
                        resolving++;
                        var apath = binpath;
                        var aname = new System.Reflection.AssemblyName(args.Name);
                        aname.CodeBase = Path.Combine(apath, args.Name + ".dll");
                        return(resolving > 1 ? null : System.Reflection.Assembly.Load(aname));
                    } catch {
                        return(null);
                    } finally {
                        resolving--;
                    }
                };
                AssemblyResolverInitialized = true;
            }

            if (Instances++ == 0)
            {
                WebCore.Initialize(new WebConfig()
                {
                    LogPath = path, LogLevel = LogLevel.Verbose
                });
            }

            if (Session == null)
            {
                Session = WebCore.CreateWebSession(new WebPreferences()
                {
                    AcceptLanguage             = Thread.CurrentThread.CurrentUICulture.Name.ToLower(),
                    DefaultEncoding            = "utf-8",
                    EnableGPUAcceleration      = false,
                    FileAccessFromFileURL      = true,
                    UniversalAccessFromFileURL = true,
                    WebAudio    = false,
                    WebGL       = true,
                    WebSecurity = false
                });
            }
            if (View == null)
            {
                View = WebCore.CreateWebView(1280, 1024, Session);
            }
            var config = new PrintConfig();

            //s.GetSize(s.Element);
            config.PageSize = new AweRect(0, 0, (int)(double.Parse(width) + 0.5), (int)(double.Parse(height) + 0.5));
            config.SplitPagesIntoMultipleFiles = false;
            var Dpi = 600.0;

            double.TryParse(dpi, out Dpi);
            config.Dpi = Dpi;
            IDisposable fileLock = null;

            SavedSignal.Reset();
            View.PrintComplete += (sender, args) => {
                File.Move(args.Files [0], localfile);
                Environment.Exit(0);
            };
            View.PrintFailed += (sender, args) => {
                Environment.Exit(1);
            };
            var    loaded   = false;
            Action onloaded = () => {
                lock (Lock) {
                    if (loaded)
                    {
                        return;
                    }
                    var part = !string.IsNullOrWhiteSpace(elementname);
                    if (part)
                    {
                        View.ExecuteJavascript(@"
						var obj = top.document.getElementById('"                         + elementname + @"');
						var selection = window.getSelection();
						var range = document.createRange();
						range.setStartBefore(obj);
						range.setEndAfter(obj) ;
						selection.addRange(range);
					"                    );
                        config.PrintSelectionOnly = true;
                    }
                    else
                    {
                        config.PrintSelectionOnly = false;
                    }
                    //FileLock = s.Compiler.FileLock(tempFile);
                    View.PrintToFile(path, config);
                    loaded = true;
                }
            };

            View.LoadingFrameComplete += (sender, args) => { if (args.IsMainFrame)
                                                             {
                                                                 onloaded();
                                                             }
            };
            View.LoadingFrameFailed += (sender, args) => { if (args.IsMainFrame)
                                                           {
                                                               onloaded();
                                                           }
            };

            View.Source = new Uri(source);
            while (View.IsLoading)
            {
                Thread.Sleep(100); WebCore.Update();
            }
            Thread.Sleep(300);
            WebCore.Update();
            onloaded();
            while (View.IsPrinting)
            {
                Thread.Sleep(100); WebCore.Update();
            }
        }
Beispiel #8
0
        public Model.GeneralReturns Print(Model.M_Print.Request S)
        {
            Model.GeneralReturns genRet = new Model.GeneralReturns();


            if (!string.IsNullOrEmpty(S.repair))
            {
                return(SupplementPrint(genRet, S));
            }

            if (String.IsNullOrEmpty(S.operateMan) || String.IsNullOrEmpty(S.operateSite) || null == S.PackaginBillcode || S.PackaginBillcode.Count == 0)
            {
                genRet.MsgText = "参数不全,请核实";
            }
            else
            {
                List <Model.M_Print.Return> reqList = new List <Model.M_Print.Return>();
                pmw_order orderInfo        = new DAL.Dal_Print().getOrderInfo(long.Parse(S.orderID));
                int       subcontractCount = 0;
                if (orderInfo.subpackageNum == null || orderInfo.subpackageNum < 1)
                {
                    subcontractCount = 1;
                }
                else
                {
                    subcontractCount = int.Parse(orderInfo.subpackageNum.ToString());
                }


                for (int i = 1; i <= subcontractCount; i++)
                {
                    if (orderInfo == null)
                    {
                        genRet.MsgText = "无法获取订单信息";
                    }
                    else
                    {
                        List <string> billcodeList = new List <string>();
                        foreach (var billcode in S.PackaginBillcode)
                        {
                            billcodeList.Add(i == 1 ? billcode.billcode : billcode.billcode + "-" + i);
                        }

                        string        message         = string.Empty;        //错误消息
                        StringBuilder strBuiGoodsCode = new StringBuilder(); //货物类型代码
                        StringBuilder strBuiGoodsType = new StringBuilder(); //货物类型
                        StringBuilder strBuiGoodsName = new StringBuilder(); //货物名称
                        double        billcodeWeight  = 0;

                        if (!IsPackage(orderInfo.order_code, i, billcodeList, ref message, ref strBuiGoodsType, ref strBuiGoodsName, ref billcodeWeight))
                        {
                            genRet.MsgText = message;
                            return(genRet);
                        }
                        #region 代收货款
                        var collectingMoney = orderInfo.pay_type == 1 ? (orderInfo.country_free + orderInfo.agencyFund) : orderInfo.agencyFund;
                        #endregion


                        GoodsCatalog goodsInfo = new DAL.Dal_Print().getGoodsTypeInfo(orderInfo.goodsType);
                        if (goodsInfo == null)
                        {
                            genRet.MsgText = "无法获取货物类型";
                            return(genRet);
                        }

                        strBuiGoodsCode.Append(goodsInfo.briefCode);
                        pmw_member memberInfo = new DAL.Dal_Print().getMemberInfo(orderInfo.member_id);
                        if (memberInfo == null)
                        {
                            genRet.MsgText = "无法获取会员信息";
                            return(genRet);
                        }

                        TaoBaoInfo shopInfo = new DAL.Dal_Print().getShopInfo(memberInfo.astro);
                        if (shopInfo == null)
                        {
                            genRet.MsgText = "无法获取店铺信息";
                            return(genRet);
                        }

                        pmw_house houseInfo = new DAL.Dal_Print().getHouseInfo(long.Parse(S.operateSite));
                        if (houseInfo == null)
                        {
                            genRet.MsgText = "无法获取仓库信息";
                            return(genRet);
                        }
                        pmw_timeBar flightInfo = new DAL.Dal_Print().getFlightTime(orderInfo.timeBarID);
                        if (flightInfo == null)
                        {
                            genRet.MsgText = "无法获取航班时效信息";
                            return(genRet);
                        }
                        PrintConfig printConfigInfo = PrintConfigInfo(orderInfo, S.express);
                        if (printConfigInfo == null)
                        {
                            genRet.MsgText = "无法获取打印配置信息";
                            return(genRet);
                        }

                        Forwarder forwarderInfo = new DAL.Dal_Print().getForwarderCode(printConfigInfo.pjCom, printConfigInfo.pjCode);
                        if (forwarderInfo == null)
                        {
                            genRet.MsgText = "无法获取派件公司信息";
                            return(genRet);
                        }

                        Forwarder_number forwarderNoInfo = new DAL.Dal_Print().getPrintNo(forwarderInfo.id);
                        if (forwarderNoInfo == null || string.IsNullOrEmpty(forwarderNoInfo.num))
                        {
                            genRet.MsgText = "无法获取单号";
                            return(genRet);
                        }
                        string printNo = forwarderNoInfo.num;
                        //if (new DAL.Dal_Print().getForwardingAgentNoCount(forwarderInfo.id) < 2001)
                        //{
                        //    try
                        //    {
                        //        var SentState1 = FastSocket.MaeesgeSend(new MassgeClass()
                        //        {
                        //            IsSite = true,
                        //            Mags = forwarderInfo.ForwarderName,
                        //            MagsID = "0",
                        //            Mags_Type = "HmOrderCount",
                        //            SiteOrUser = new string[] { "客服" }
                        //        }, false);
                        //    }
                        //    catch (Exception ex)
                        //    {

                        //    }
                        //}

                        string recipients = new DAL.Dal_Print().getRecipientName(orderInfo.cname, orderInfo.id);


                        string sentKdBillcode = string.IsNullOrEmpty(orderInfo.sent_kd_billcode) ? printNo : orderInfo.sent_kd_billcode + "," + printNo;
                        bool   dbPrint        = new DAL.Dal_Print().Print(Convert.ToDecimal(collectingMoney), orderInfo, sentKdBillcode, S.express.Contains("黑猫") ? "黑猫宅急便" : S.express, recipients, houseInfo, shopInfo, forwarderInfo, billcodeList.ToArray(), strBuiGoodsName.ToString(), S, printNo, billcodeWeight);
                        if (!dbPrint)
                        {
                            new DAL.Dal_Print().ReleaseForwarder_number(forwarderNoInfo);
                            genRet.MsgText = "无法生成运单";
                            return(genRet);
                        }


                        if (printConfigInfo.pjCom.Contains("国阳"))
                        {
                            ApiHelp.GYHelper gyApi = new ApiHelp.GYHelper();
                            gyApi.AddData(new ApiHelp.GYHelper.Data()
                            {
                                SentType     = S.express.Contains("取货") ? "A02" : "A01",
                                Signer       = recipients,
                                SignAddress  = orderInfo.address,
                                SignPhone    = orderInfo.mobile,
                                SignEmail    = memberInfo.email,
                                StoreName    = S.express.Contains("取货") ? recipients : "",
                                StoreCode    = S.express.Contains("取货") ? orderInfo.customerCode : "",
                                StoreAddress = S.express.Contains("取货") ? orderInfo.address : "",
                                StorePhone   = S.express.Contains("取货") ? orderInfo.mobile : "",
                                OrderCode    = printNo,
                                GoodsName    = strBuiGoodsName.ToString(),
                                GoodsAccount = billcodeList.Count,
                                DsMoney      = (int)collectingMoney,
                                Weight       = (int)billcodeWeight,
                                SentFastType = GyTransferCompanyCode(S.express)
                            });
                            gyApi.ToCsv(Common.Entity.ftpPaht, true);
                        }


                        reqList.Add(new Model.M_Print.Return
                        {
                            WaybillNo           = printNo,
                            billcode            = string.Join(",", billcodeList.ToArray()),
                            employee            = S.operateMan,
                            Js_number           = billcodeList.Count,
                            briefCode           = strBuiGoodsCode.ToString(),
                            goodsType           = strBuiGoodsType.ToString(),
                            shopName            = shopInfo.Name,
                            OrderGoodsNotes     = orderInfo.OrderGoodsNotes,
                            CusCode             = forwarderInfo.ForwarderCode,
                            timeBarName         = flightInfo.timeBarName,
                            orderID             = orderInfo.id.ToString(),
                            z_weight            = billcodeWeight.ToString(),
                            address             = orderInfo.address,
                            Phone               = orderInfo.mobile,
                            recipients          = recipients,
                            IdentificationGoods = strBuiGoodsType.ToString().Contains("特") ? "T" : "",
                            ds_mdgj_Free        = orderInfo.pay_type == 1 ? Math.Round(Convert.ToDecimal(orderInfo.agencyFund + orderInfo.country_free), 2).ToString() : "0",
                            DFFeer              = collectingMoney.ToString(),
                            addressCode         = printNo.Substring(6),
                            goodsName           = strBuiGoodsName.ToString(),
                            chargedWeight       = orderInfo.Free_Weight.ToString()
                        });
                        genRet.State      = true;
                        genRet.Mb         = S.express;
                        genRet.ReturnJson = Common.DataHandling.ObjToJson(reqList);
                        genRet.MsgText    = S.operateMan;
                    }
                }
            }

            return(genRet);
        }
Beispiel #9
0
        private DriverKitchenPrint(string printerName, string paperName, string paperType)
        {
            string printConfigPath = AppDomain.CurrentDomain.BaseDirectory + "PrintConfig\\KitchenPrintSetting.config";

            if (!File.Exists(printConfigPath))
            {
                throw new ArgumentNullException("Print config file does not exist.");
            }
            DriverPrintSetting printSetting = XmlUtil.Deserialize <DriverPrintSetting>(printConfigPath);

            if (printSetting != null && printSetting.PrintConfigs != null && printSetting.PrintConfigs.Count > 0)
            {
                foreach (PrintConfig printConfig in printSetting.PrintConfigs)
                {
                    if (printConfig.PaperType == paperType)
                    {
                        _curPrintConfig = printConfig;
                        break;
                    }
                }
            }
            if (_curPrintConfig != null)
            {
                if (_curPrintConfig.PrintLayouts != null && _curPrintConfig.PrintLayouts.LayoutList != null && _curPrintConfig.PrintLayouts.LayoutList.Count > 0)
                {
                    foreach (var printLayout in _curPrintConfig.PrintLayouts.LayoutList)
                    {
                        if (printLayout.Key.Equals("KitchenPrint", StringComparison.CurrentCultureIgnoreCase))
                        {
                            _kitchenPrintLayoutPath = string.Format("{0}PrintConfig\\{1}", AppDomain.CurrentDomain.BaseDirectory, printLayout.Value);
                        }
                        else if (printLayout.Key.Equals("DeskChangePrint", StringComparison.CurrentCultureIgnoreCase))
                        {
                            _deskChangePrintLayoutPath = string.Format("{0}PrintConfig\\{1}", AppDomain.CurrentDomain.BaseDirectory, printLayout.Value);
                        }
                    }
                }
            }
            else
            {
                throw new ArgumentNullException(string.Format("Can not find the {0} paper type.", paperType));
            }
            int width = 283, height = 1869;

            if (paperType.Equals("58mm", StringComparison.CurrentCultureIgnoreCase))
            {
                width = 203;
            }
            else if (paperType.Equals("76mm", StringComparison.CurrentCultureIgnoreCase))
            {
                width = 268;
            }
            else if (paperType.Equals("80mm", StringComparison.CurrentCultureIgnoreCase))
            {
                width = 283;
            }
            _printDocument = new PrintDocument();
            _printDocument.PrinterSettings.PrinterName = printerName;
            PaperSize paperSize = new PaperSize(paperName, width, height);//页面大小;

            foreach (PaperSize ps in _printDocument.PrinterSettings.PaperSizes)
            {
                if (ps.PaperName.Equals(paperName))
                {
                    paperSize = ps;
                }
            }
            _printDocument.DefaultPageSettings.PaperSize = paperSize;
            _printDocument.DefaultPageSettings.Landscape = false;//横向打印
            _printDocument.PrintPage += new PrintPageEventHandler(pDoc_PrintPage);
        }
Beispiel #10
0
 static void printWithConfig(PrintConfig config)
 {
     bookNodes.ForEach(node => Console.WriteLine(node.ToStringWith(config)));
 }
        public bool GenerateDocument(PrintForm form)
        {
            var config = new PrintConfig()
            {
                EvictionIds = new string[] { form.EvictionId },
                Forms = new string[] { form.FormName },
                PrintCount = new string[] { form.Copies },
                SelectedAttorney = form.Attorney,
                UserId = form.UserId,
                ParentUserId = form.ParentUserId,
                TemplateFolder =ConfigurationSettings.AppSettings["TemplateFolder"],//  @"E:\CASS TFS\Eviction  Site\Eviction_v1.0-Printing Tool\website\nwe2.0",
                MappingFolder = ConfigurationSettings.AppSettings["MappingFolder"] ,
                UserType = form.UserType ,
                ReIssueCheck =!string.IsNullOrEmpty(form.ReIssueCheck )&& Convert.ToBoolean( form.ReIssueCheck),

            };

            try
            {
               //form.FilePath =  PrintingTool.Print(config);
               // conectar la forma en la que se genera el documento.

                return !string.IsNullOrEmpty(form.FilePath);
            }
            catch (Exception ex)
            {
                ex.WriteLog();
                return false;
            }
        }