Example #1
0
        public override void Print(CloudPrintJob job)
        {
            using (Ghostscript gs = new Ghostscript())
            {
                PrintTicket   printTicket = job.GetPrintTicket();
                byte[]        printData   = job.GetPrintData();
                List <string> args        = new List <string>();

                args.Add("-dAutoRotatePages=/None");

                if (printTicket.OutputColor != OutputColor.Color)
                {
                    args.Add("-sColorConversionStrategy=Gray");
                    args.Add("-dProcessColorModel=/DeviceGray");
                }

                byte[] printdata = gs.ProcessData(printTicket, printData, "pdfwrite", args.ToArray(), null);

                WindowsRawPrintJob pj = new WindowsRawPrintJob
                {
                    JobName     = job.JobTitle,
                    UserName    = job.Username,
                    PrinterName = job.Printer.Name,
                    PrintData   = printdata,
                    RunAsUser   = true
                };

                pj.Print();
            }
        }
Example #2
0
        protected void PrintData(string username, PrintTicket ticket, string printername, string jobname, byte[] data, string driver)
        {
            using (Ghostscript gs = new Ghostscript())
            {
                if (driver != null)
                {
                    byte[] outdata = gs.ProcessData(ticket, data, driver, null, null);

                    WindowsRawPrintJob pj = new WindowsRawPrintJob
                    {
                        JobName     = jobname,
                        PrinterName = printername,
                        UserName    = username,
                        PrintData   = outdata,
                        RunAsUser   = true
                    };

                    pj.Print();
                }
                else
                {
                    gs.PrintData(username, ticket, printername, jobname, data, new string[] { });
                }
            }
        }
Example #3
0
        protected void PrintData(string username, PrintTicket ticket, string printername, string jobname, byte[] data, Dictionary <string, string> pjljobattribs)
        {
            using (Ghostscript gs = new Ghostscript())
            {
                string driver = ticket.OutputColor == OutputColor.Color ? "pxlcolor" : "pxlmono";

                byte[] pcldata = gs.ProcessData(ticket, data, driver, null, null);

                PaginatedPrintData pcljob = ProcessPCL(pcldata, pjljobattribs, ticket);
                WindowsRawPrintJob job    = new WindowsRawPrintJob
                {
                    PagedData   = pcljob,
                    JobName     = jobname,
                    PrinterName = printername,
                    UserName    = username,
                    RunAsUser   = true
                };

                job.Print();
            }
        }
Example #4
0
        protected void Print(CloudPrintJob job, bool runAsUser, bool usePJL, Dictionary <string, string> pjljobattribs, Dictionary <string, string> pjlsettings)
        {
            PrintTicket        ticket   = job.GetPrintTicket();
            PaginatedPrintData pagedjob = PostscriptHelper.FromPDF(job.GetPrintData(), ticket);

            if (usePJL)
            {
                pagedjob.Prologue = PJLHelper.GetPJL(pjljobattribs, pjlsettings, "POSTSCRIPT").Concat(pagedjob.Prologue).ToArray();
            }

            WindowsRawPrintJob pj = new WindowsRawPrintJob
            {
                PagedData   = pagedjob,
                JobName     = job.JobTitle,
                PrinterName = job.Printer.Name,
                UserName    = job.Username,
                PrintTicket = ticket,
                RunAsUser   = runAsUser
            };

            pj.Print();
        }