Beispiel #1
0
        public async Task <bool> ExportPreview1(string output)
        {
            await Task.Run(() =>
            {
                string[] args =
                {
                    "gs",
                    "-dBATCH",
                    "-dSAFER",
                    "-sDEVICE=png16m",
                    "-sOutputFile=" + output,
                    "-dTextAlphaBits=4",
                    "-dGraphicsAlphaBits=4",
                    "-r120",
                    "-dFirstPage=1",
                    "-dLastPage=1",
                    "-f",
                    FileName
                };
                int result = GSDLL.Execute(args);
            });

            return(true);
        }
Beispiel #2
0
        public void Print(string printer, string jobname, int paper = 0, Color color = Color.AUTO, Duplex duplex = Duplex.SIMPLEX, bool collate = true, int copies = 1)
        {
            if (System.IO.File.Exists(fileName))
            {
                string duplex1 = "";
                switch (duplex)
                {
                case Duplex.SIMPLEX:
                    break;

                case Duplex.VERTICAL:
                    duplex1 = "/Duplex true /Tumble false ";
                    break;

                case Duplex.HORIZONTAL:
                    duplex1 = "/Duplex true /Tumble true ";
                    break;
                }

                string color1 = "/BitsPerPixel 24 ";
                string color2 = "/Color 2 ";
                if (color == Color.MONO)
                {
                    color2 = "/Color 1 ";
                }

                string paper1 = "/Paper 9 ";
                if (paper > 0)
                {
                    paper1 = "/Paper " + Convert.ToInt32(paper) + " ";
                }

                string ignore1 = "";
                if (collate)
                {
                    ignore1 = "/.IgnoreNumCopies true ";
                }
                else
                {
                    copies = 1;
                }

                string[] args =
                {
                    "gs",
                    "-c",
                    "mark " +
                    "/NoCancel true " +
                    "/OutputFile (%printer%" + (printer == null ? "" : printer) + ") " +
                    color1 +
                    duplex1 +
                    ignore1 +
                    "/UserSettings " +
                    "<<" +
                    "/DocumentName (" + jobname + ") " +
                    paper1 +
                    "/Orientation 1 " +
                    color2 +
                    duplex1 +
                    ">> " +
                    "(mswinpr2) finddevice " +
                    "putdeviceprops " +
                    "setdevice",
                    "-dBATCH",
                    "-dNOPAUSE",
                    "-dSAFER",
                    "-f",
                    this.fileName
                };
                for (int i = 0; i < copies; i++)
                {
                    GSDLL.Execute(args);
                }
            }
        }
Beispiel #3
0
        public async Task <bool> Analyze()
        {
            bool ret = false;

            await Task.Run(() =>
            {
                // インク消費量からカラー/モノクロのページ数を算出
                string[] args =
                {
                    "gs",
                    "-dBATCH",
                    "-dNOPAUSE",
                    "-dSAFER",
                    "-dNoCancel",
                    "-sDEVICE=inkcov",
                    "-sOutputFile=" + InkFileName,
                    "-r75",
                    "-f",
                    FileName
                };
                int result = GSDLL.Execute(args);

                Microsoft.VisualBasic.FileIO.TextFieldParser tfp = new Microsoft.VisualBasic.FileIO.TextFieldParser(InkFileName);
                tfp.Delimiters = new string[] { " " };
                while (!tfp.EndOfData)
                {
                    string[] fields = tfp.ReadFields();
                    double[] ink    = { 0.0, 0.0, 0.0, 0.0 };
                    int i           = 0;
                    foreach (string s in fields)
                    {
                        if (s.Length > 0)
                        {
                            ink[i] = Convert.ToDouble(s);
                            i++;
                        }
                        if (i > 3)
                        {
                            break;
                        }
                    }
                    if (ink[0] + ink[1] + ink[2] > 0.0)
                    {
                        Pages.Color++;
                    }
                    else if (ink[3] > 0.0)
                    {
                        Pages.Mono++;
                    }
                    else
                    {
                        Pages.Blank++;
                    }
                }
                tfp.Close();
                ret = true;
                FILEUTIL.SafeDelete(InkFileName);
            });

            return(ret);
        }