コード例 #1
0
        static public void PrintDoc2(PrintDocArgs Args, int TryCount)
        {
            int             W   = 268; //268
            double          H   = 5000;
            ctrlCheckVisual vis = new ctrlCheckVisual();

            if (Args.FStrs != null)
            {
                BitmapImage QrImg = FiscalCheckCreator.CreateQRBitmap(Args.QRAsStr, 130, 130);
                vis.CreateCheck(Args.FStrs, QrImg);
                vis.Visibility = Visibility.Visible;
                // string PrName = @"Predchek4";
                string PrName = iniFile.FRSPrinterName;
                try
                {
                    Utils.ToCardLog("PrintDoc PrName " + PrName);
                    PrintDialog Pd = new PrintDialog();
                    Pd.PageRangeSelection = PageRangeSelection.AllPages;
                    PrintServer Ps = new PrintServer();
                    PrintQueue  PQ = new PrintQueue(Ps, PrName);
                    Pd.PrintQueue = PQ;
                    // Pd.ShowDialog();
                    PrintTicket Pt = Pd.PrintTicket;
                    Pt.PageMediaSize     = new PageMediaSize(W, 11349);
                    Pt.PageBorderless    = PageBorderless.Borderless;
                    Pt.PageResolution    = new PageResolution(203, 203);
                    Pt.PageScalingFactor = 1;
                    Pt.TrueTypeFontMode  = TrueTypeFontMode.DownloadAsRasterFont;

                    Size pageSize = new Size(W - 10, Pd.PrintableAreaHeight);
                    //pageSize = new Size(W, H);
                    ((UserControl)vis).Measure(pageSize);
                    ((UserControl)vis).Arrange(new Rect(0, 0, W - 10, ((UserControl)vis).Height));
                    //((UserControl)vis).Arrange(new Rect(0, 0, W, H));
                    if (iniFile.FRSSaveCheckToImg2)
                    {
                        SaveCheckVisualToFile(vis, W, Convert.ToInt32(((UserControl)vis).Height));
                    }
                    Pd.PrintVisual(vis, "Hello");
                    Ps.Dispose();
                    Pd.PrintQueue.Dispose();

                    Pd    = null;
                    QrImg = null;
                }
                catch (Exception e)
                {
                    Utils.ToCardLog("PrintDoc Error " + e.Message);
                    if (TryCount < 5)
                    {
                        Utils.ToCardLog("Try again " + TryCount);
                        System.Threading.Thread.Sleep(300);
                        GC.Collect();
                        PrintDoc2(Args, TryCount + 1);
                    }
                }
            }
            vis = null;
            GC.Collect();
        }
コード例 #2
0
 static public void PrintDoc2(PrintDocArgs Args)
 {
     PrintDoc2(Args, 0);
 }