Exemple #1
0
        public static void Run()
        {
            // Create a print job with the document to be printed to the default printer
            PrintJob printJob = new PrintJob(Printer.Default);

            // Add pages to the print job from multiple PDFs
            printJob.Pages.Add(Util.GetPath("Resources/DocumentA1.pdf"));
            printJob.Pages.Add(Util.GetPath("Resources/DocumentB1.pdf"));
            printJob.Pages.Add(Util.GetPath("Resources/DocumentC1.pdf"));
            printJob.Pages.Add(Util.GetPath("Resources/DocumentD1.pdf"));

            // Create a MultiplepagePageScalling class and set the properties
            MultipagePageScaling multipagePageScaling = new MultipagePageScaling(4, 2);

            multipagePageScaling.Border         = new Border(Color.Green, 2);
            multipagePageScaling.Margin         = new Margin(5, 5, 5, 5);
            multipagePageScaling.Spacing        = new Spacing(2, 2);
            multipagePageScaling.UniformScaling = true;

            // Add the class to the PrintOptions Scaling property
            printJob.PrintOptions.Scaling = multipagePageScaling;

            // Print the print job
            printJob.Print();
        }
Exemple #2
0
        public async static void PrintZpl(ThermalLabel label, string filePath, string printerName, int copies)
        {
            string zpl = "";

            using (var pj = new PrintJob())
            {
                pj.ThermalLabel        = label;
                pj.ProgrammingLanguage = ProgrammingLanguage.ZPL;
                zpl = pj.GetNativePrinterCommands();
            }

            if (!System.IO.Directory.Exists("PDFservices\\Data"))
            {
                System.IO.Directory.CreateDirectory("PDFservices\\Data");
            }

            string filepath = System.IO.Path.Combine("PDFservices\\Data", Guid.NewGuid() + ".zpl");

            System.IO.File.WriteAllText(filePath, zpl);

            while (copies > 0)
            {
                Console.WriteLine("sending to printer");
                await PDFPrinting.SendRawCmdToPrinter(filePath, printerName);

                copies--;
            }
        }
Exemple #3
0
        public static void Run()
        {
            // Create a print job with the document to be printed to the default printer
            PrintJob printJob = new PrintJob(Printer.Default, Util.GetPath("Resources/DocumentA.pdf"), 2, 2);

            // Set resolution to high
            printJob.PrintOptions.Resolution = ResolutionList.High;

            // Set the print priority
            printJob.PrintPriority = 2;

            // Sent the print scaling
            printJob.PrintOptions.Scaling = new PercentagePageScaling(0.5f);

            // Set the page orientation
            printJob.PrintOptions.Orientation.Type = OrientationType.Portrait;

            // Set the option to print in color
            if (printJob.Printer.Color)
            {
                printJob.PrintOptions.Color = true;
            }

            // Print the print job
            printJob.Print();
        }
Exemple #4
0
    public static List <PrintJob> GetPrintJobs(string printerToFind)
    {
        List <PrintJob> printJobs   = new List <PrintJob>();
        string          searchQuery = "SELECT * FROM Win32_PrintJob";

        /*searchQuery can also be mentioned with where Attribute,
         *  but this is not working in Windows 2000 / ME / 98 machines
         *  and throws Invalid query error*/
        ManagementObjectSearcher   searchPrintJobs = new ManagementObjectSearcher(searchQuery);
        ManagementObjectCollection searchResults   = searchPrintJobs.Get();

        foreach (ManagementObject wmiPrintJob in searchResults)
        {
            PrintJob printJob = new PrintJob();
            printJob.Name = wmiPrintJob.Properties["Name"].Value.ToString();


            //Job name would be of the format [Printer name], [Job ID]
            char[] splitArr = new char[1];
            splitArr[0] = Convert.ToChar(",");

            printJob.PrinterName = printJob.Name.Split(splitArr)[0];
            if (string.IsNullOrEmpty(printerToFind) || printerToFind == printJob.PrinterName)
            {
                printJob.Document = wmiPrintJob.Properties["Document"].Value.ToString();
                printJob.Driver   = wmiPrintJob.Properties["DriverName"].Value.ToString();
                printJob.Owner    = wmiPrintJob.Properties["Owner"].Value.ToString();

                printJobs.Add(printJob);
            }
        }
        return(printJobs);
    }
        /// <summary>
        /// Gets the print job.
        /// </summary>
        /// <param name="jobId">The job id.</param>
        /// <returns></returns>
        public static PrintJob GetPrintJob(uint?jobId)
        {
            List <PrintJob> printJobs   = new List <PrintJob>();
            string          searchQuery = "SELECT * FROM Win32_PrintJob";

            /*searchQuery can also be mentioned with where Attribute,
             *  but this is not working in Windows 2000 / ME / 98 machines
             *  and throws Invalid query error*/
            ManagementObjectSearcher   searchPrintJobs = new ManagementObjectSearcher(PrintServerScope(), searchQuery);
            ManagementObjectCollection searchResults   = searchPrintJobs.Get();
            PrintJob printJob = null;

            foreach (ManagementObject wmiPrintJob in searchResults)
            {
                if (jobId == (uint?)wmiPrintJob.Properties["JobId"].Value)
                {
                    printJob = new PrintJob();
                    PopulatePrintJob(printJob, wmiPrintJob);
                    printJobs.Add(printJob);
                    break;
                }
            }

            return(printJob);
        }
Exemple #6
0
        private void button2_Click(object sender, EventArgs e)
        {
            string      printername = "";
            PrintDialog pd          = new PrintDialog();

            if (pd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                printername = pd.PrinterSettings.PrinterName;
                try
                {
                    HtmlToPdfConverter htmlToPdfConverter = new HtmlToPdfConverter();
                    htmlToPdfConverter.LicenseKey      = "sjwvPS4uPSskPSgzLT0uLDMsLzMkJCQk";
                    htmlToPdfConverter.HtmlViewerWidth = 850;
                    htmlToPdfConverter.PdfDocumentOptions.AvoidImageBreak = true;

                    byte[] outPdfBuffer = htmlToPdfConverter.ConvertHtml(winFormHtmlEditor1.DocumentHtml, "");


                    InputPdf inputPdf = new InputPdf(outPdfBuffer);
                    //PrinterSettings settings = new PrinterSettings();
                    PrintJob printJob = new PrintJob(printername, inputPdf);
                    printJob.DocumentName = ReportCombo.Text.Replace(" ", "_").Replace("/", "");
                    PrintJob.AddLicense("FPM20NXDLB2DHPnggbYuVwkquSU3u2ffoA/Pgph4rjG5wiNCxO8yEfbLf2j90rZw1J3VJQF2tsniVvl5CxYka6SmZX4ak6keSsOg");
                    printJob.PrintOptions.Scaling = new AutoPageScaling();
                    printJob.Print();
                }
                catch (Exception ee)
                {
                    Logger.Instance.WriteToLog(ee.ToString());
                }
            }
        }
        /// <summary>
        /// Gets the print jobs.
        /// </summary>
        /// <param name="printerToFind">The warehouse to get a list of print jobs for.</param>
        /// <param name="sortExpression">The sort expression.</param>
        /// <returns></returns>
        public static List <PrintJob> GetPrintJobs(string printerToFind, string sortExpression)
        {
            List <PrintJob> printJobs = new List <PrintJob>();

            string searchQuery = "SELECT * FROM Win32_PrintJob";

            /*searchQuery can also be mentioned with where Attribute,
             *  but this is not working in Windows 2000 / ME / 98 machines
             *  and throws Invalid query error*/
            ManagementObjectSearcher   searchPrintJobs = new ManagementObjectSearcher(PrintServerScope(), searchQuery);
            ManagementObjectCollection searchResults   = searchPrintJobs.Get();

            foreach (ManagementObject wmiPrintJob in searchResults)
            {
                //Job name would be of the format [Printer name], [Job ID]


                if (!string.IsNullOrEmpty(printerToFind) &&
                    printerToFind == wmiPrintJob.Properties["Name"].Value.ToString().Split(',')[0])
                {
                    PrintJob printJob = new PrintJob();
                    PopulatePrintJob(printJob, wmiPrintJob);
                    printJobs.Add(printJob);
                }
            }
            if (string.IsNullOrEmpty(sortExpression))
            {
                sortExpression = "Name";
            }
            printJobs.Sort(new UniversalComparer <PrintJob>(sortExpression));

            return(printJobs);
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            //Define a ThermalLabel object and set unit to inch and label size
            ThermalLabel tLabel = new ThermalLabel(Neodynamic.SDK.Printing.UnitType.Inch, 1, 0.5);

            tLabel.GapLength = 0.2;



            //Define a BarcodeItem object

            BarcodeItem bcItem = new BarcodeItem(0.2, 0.2, 0.4, 0.6, BarcodeSymbology.Code128, TextBox1.Text);

            //Set bars height to .75inch
            //bcItem.BarHeight = 0.04;
            //Set bars width to 0.0104inch
            //bcItem.BarWidth = 0.06;
            bcItem.Tag = "";

            //Create a PrintJob object

            //Create a PrintJob object
            using (PrintJob pj = new PrintJob())
            {
                tLabel.Items.Add(bcItem);

                //Save output to image...
                pj.ExportToImage(tLabel, Server.MapPath("/myLabel.jpeg"), new ImageSettings(ImageFormat.Jpeg), 1000);
            }
            Image image = new Image();

            image.ImageUrl = "/myLabel.jpeg";
            this.Page.Form.Controls.Add(image);
        }
Exemple #9
0
        private void btnPQ_Click(object sender, EventArgs e)
        {
            int intStart = 1564;
            int intEnd   = 1564;



            int countInside = intStart;

            for (int j = 0; countInside <= intEnd; j++)
            {
                for (int i = 0; i < 2; i++)
                {
                    ThermalLabel _currentThermalLabel = null;
                    _currentThermalLabel = this.GenerateBasicThermalLabel222(countInside);

                    //Neodynamic.SDK.Printing.PrinterSettings _printerSettings = new Neodynamic.SDK.Printing.PrinterSettings();
                    Neodynamic.SDK.Printing.PrinterSettings _printerSettings = new Neodynamic.SDK.Printing.PrinterSettings();
                    _printerSettings.Communication.CommunicationType = CommunicationType.USB;
                    _printerSettings.PrinterName         = _Printer;
                    _printerSettings.Dpi                 = 203;
                    _printerSettings.ProgrammingLanguage = (ProgrammingLanguage)Enum.Parse(typeof(ProgrammingLanguage), "ZPL");
                    PrintOrientation _printOrientation = PrintOrientation.Portrait;

                    using (PrintJob pj = new PrintJob(_printerSettings))
                    {
                        pj.PrintOrientation = _printOrientation;
                        pj.ThermalLabel     = _currentThermalLabel;
                        pj.Print();
                    }
                }
                countInside++;
            }
        }
Exemple #10
0
        public static PrintJob PrintHTML(Activity BaseActivity, string HTMLContent, string DocName = "")
        {
            try
            {
                // Create a WebView object specifically for printing
                WebView webView = new WebView(BaseActivity);
                webView.SetWebViewClient(new WebViewClient());

                // Generate an HTML document on the fly:
                webView.LoadDataWithBaseURL(null, HTMLContent, "text/HTML", "UTF-8", null);
                String htmlDocument = HTMLContent;

                // Get a print adapter instance
                PrintDocumentAdapter printDocumentAdapter = webView.CreatePrintDocumentAdapter(DocName);

                // Get a PrintManager instance
                PrintManager printManager = (PrintManager)BaseActivity.GetSystemService(Context.PrintService);

                // Keep a reference to WebView object until you pass the PrintDocumentAdapter to the PrintManager
                PrintJob printJob = printManager.Print(DocName, printDocumentAdapter, new PrintAttributes.Builder().Build());
                return(printJob);
            }
            catch (Exception Ex)
            {
                WriteErrorLog(Ex);
                return(null);
            }
        }
Exemple #11
0
        public async Task PrintJobBase64CreateTest()
        {
            var job = new PrintJob
            {
                printerId   = 70367312,
                title       = $"Test {DateTime.Now}",
                contentType = "raw_base64",
                content     = Convert.ToBase64String(Encoding.ASCII.GetBytes(File.ReadAllText("test.zpl"))),
                source      = "test"
            };
            var created = await _client.CreatePrintJobAsync(job);

            var job2 = new PrintJob
            {
                printerId   = 70367312,
                title       = $"Test {DateTime.Now}",
                contentType = "raw_base64",
                content     = Convert.ToBase64String(Encoding.ASCII.GetBytes(File.ReadAllText("test.zpl"))),
                source      = "test"
            };
            var created2 = await _client.CreatePrintJobAsync(job2);

            var job3 = new PrintJob
            {
                printerId   = 70367312,
                title       = $"Test {DateTime.Now}",
                contentType = "raw_base64",
                content     = Convert.ToBase64String(Encoding.ASCII.GetBytes(File.ReadAllText("test.zpl"))),
                source      = "test"
            };
            var created3 = await _client.CreatePrintJobAsync(job3);

            Assert.True(created > 0);
        }
Exemple #12
0
        public static void PrintOrders(PrintJob printJob, Ticket ticket)
        {
            if (printJob.ExcludeVat)
            {
                ticket = ObjectCloner.Clone(ticket);
                ticket.TicketItems.ToList().ForEach(x => x.VatIncluded = false);
            }

            IEnumerable <TicketItem> ti;

            switch (printJob.WhatToPrint)
            {
            case (int)WhatToPrintTypes.NewLines:
                ti = ticket.GetUnlockedLines();
                break;

            case (int)WhatToPrintTypes.GroupedByBarcode:
                ti = GroupLinesByValue(ticket, x => x.Barcode ?? "", "1", true);
                break;

            case (int)WhatToPrintTypes.GroupedByGroupCode:
                ti = GroupLinesByValue(ticket, x => x.GroupCode ?? "", Resources.UndefinedWithBrackets);
                break;

            case (int)WhatToPrintTypes.GroupedByTag:
                ti = GroupLinesByValue(ticket, x => x.Tag ?? "", Resources.UndefinedWithBrackets);
                break;

            case (int)WhatToPrintTypes.LastLinesByPrinterLineCount:
                ti = GetLastItems(ticket, printJob);
                break;

            case (int)WhatToPrintTypes.LastPaidItems:
                ti     = GetLastPaidItems(ticket).ToList();
                ticket = ObjectCloner.Clone(ticket);
                ticket.TicketItems.Clear();
                ticket.PaidItems.Clear();
                ticket.Payments.Clear();
                ti.ToList().ForEach(x => ticket.TicketItems.Add(x));
                break;

            default:
                ti = ticket.TicketItems.OrderBy(x => x.Id).ToList();
                break;
            }

            Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle,
                                                       new Action(
                                                           delegate
            {
                try
                {
                    InternalPrintOrders(printJob, ticket, ti);
                }
                catch (Exception e)
                {
                    AppServices.LogError(e, string.Format(Resources.PrintingErrorMessage_f, e.Message));
                }
            }));
        }
Exemple #13
0
        public static async Task Main(string[] args)
        {
            //Create our actor system and JobManager for the print job
            var actorSystem = ActorSystem.Create("print-job-system", Configuration.Config);

            var jobManager = actorSystem.ActorOf(
                Props.Create(
                    () => new JobManager <PrintJobScheduler, PrintJobRunner, PrintJob, PrintJobId>(
                        (() => new PrintJobScheduler()),
                        () => new PrintJobRunner())));

            var jobId    = PrintJobId.New;
            var job      = new PrintJob("repeated job");
            var interval = TimeSpan.FromSeconds(10);
            var when     = DateTime.UtcNow;

            //Create a message that will Ack with [Success] and will fail with [Failed]
            var scheduleMessage = new ScheduleRepeatedly <PrintJob, PrintJobId>(jobId, job, interval, when)
                                  .WithAck(Success.Instance)
                                  .WithNack(Failed.Instance);

            var scheduled = await jobManager.Ask <PrintJobResponse>(scheduleMessage);

            var result = scheduled
                         .Match()
                         .With <Success>(x => Console.WriteLine("Job was Scheduled"))
                         .With <Failed>(x => Console.WriteLine("Job was NOT scheduled."))
                         .WasHandled;

            Console.ReadLine();
        }
Exemple #14
0
        public static async Task <List <string> > RunSimulatedPrint(this PrinterConfig printer, Stream inputStream)
        {
            // set up our serial port finding
            FrostedSerialPortFactory.GetPlatformSerialPort = (_) =>
            {
                return(new Emulator());
            };

            FrostedSerialPort.AllowEmulator = true;

            var sentLines = new List <string>();

            // register to listen to the printer responses
            printer.Connection.LineSent += (s, line) =>
            {
                if (printer.Connection.Printing)
                {
                    sentLines.Add(line);
                }
            };

            // set up the emulator
            printer.Settings.SetValue($"{Environment.MachineName}_com_port", "Emulator");

            // connect to the emulator
            printer.Connection.Connect();

            var timer = Stopwatch.StartNew();

            // wait for the printer to be connected
            while (!printer.Connection.IsConnected &&
                   timer.ElapsedMilliseconds < (1000 * 40))
            {
                Thread.Sleep(100);
            }

            // TODO: Reimplement
            // start a print
            printer.Connection.CommunicationState = CommunicationStates.PreparingToPrint;
            // await printer.Connection.StartPrint(inputStream);

            var printTask = new PrintJob()
            {
                PrintStart = DateTime.Now,
                PrinterId  = printer.Settings.ID.GetHashCode(),
            };

            printer.Connection.StartPrint(inputStream, printTask);

            // wait up to 40 seconds for the print to finish
            timer = Stopwatch.StartNew();
            while (printer.Connection.Printing &&
                   timer.ElapsedMilliseconds < (1000 * 40))
            {
                Thread.Sleep(100);
            }

            // Project to string without checksum which is not an M105 request
            return(sentLines.Select(l => GCodeFile.GetLineWithoutChecksum(l)).Where(l => !l.StartsWith("M105")).ToList());
        }
Exemple #15
0
        public void AddValue(int key, PrintJob printJob)
        {
            _printjobs.TryGetValue(key, out List <PrintJob> list);
            list.Add(printJob);

            _printjobs[key] = list;
        }
        private void btnPrint_Click(object sender, EventArgs e)
        {
            //warning about label size
            string msg = LABEL_NOTE_3x2;

            if (_currentDemoIndex == 0 ||
                _currentDemoIndex == 1 ||
                _currentDemoIndex == 5)
            {
                msg = LABEL_NOTE_4x3;
            }

            if (MessageBox.Show(msg, "NOTE", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }


            //Display Print Job dialog...
            PrintJobDialog frmPrintJob = new PrintJobDialog();

            if (frmPrintJob.ShowDialog() == DialogResult.OK)
            {
                //create a PrintJob object
                using (PrintJob pj = new PrintJob(frmPrintJob.PrinterSettings))
                {
                    pj.Copies           = frmPrintJob.Copies;           // set copies
                    pj.PrintOrientation = frmPrintJob.PrintOrientation; //set orientation
                    pj.ThermalLabel     = _currentThermalLabel;         // set the ThermalLabel object
                    pj.Print();                                         // print the ThermalLabel object
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {//Define a ThermalLabel object and set unit to inch and label size
         //Define a ThermalLabel object and set unit to inch and label size
            ThermalLabel tLabel = new ThermalLabel(Neodynamic.SDK.Printing.UnitType.Inch, 4, 3);

            tLabel.GapLength = 0.2;

            //Define a TextItem object
            TextItem txtItem = new TextItem(0.2, 0.2, 1, 0.5, "Thermal Label Test");

            //Define a BarcodeItem object
            BarcodeItem bcItem = new BarcodeItem(0.2, 1, 2, 1, BarcodeSymbology.Code128, "12345788888888");

            //Set bars height to .75inch
            bcItem.BarHeight = 0.75;
            //Set bars width to 0.0104inch
            bcItem.BarWidth = 0.0104;

            //Add items to ThermalLabel object...
            tLabel.Items.Add(txtItem);
            tLabel.Items.Add(bcItem);

            //Create a PrintJob object
            using (PrintJob pj = new PrintJob())
            {
                //Save output to PDF...
                pj.ExportToPdf(tLabel, @"d:\develop\myLabel.pdf", 300);
            }
        }
Exemple #18
0
        private IEnumerable <Order> GetOrders(PrintJob printJob, Ticket ticket, Func <Order, bool> orderSelector)
        {
            if (printJob.ExcludeTax)
            {
                ticket.TaxIncluded = false;
            }
            IEnumerable <Order> ti;

            switch (printJob.WhatToPrint)
            {
            case (int)WhatToPrintTypes.LastLinesByPrinterLineCount:
                ti = GetLastOrders(ticket, printJob, orderSelector);
                break;

            case (int)WhatToPrintTypes.LastPaidOrders:
                ti = GetLastPaidOrders(ticket);
                break;

            case (int)WhatToPrintTypes.OrdersByQuanity:
                ti = SeparateOrders(ticket, orderSelector).OrderBy(x => x.MenuItemName);
                break;

            case (int)WhatToPrintTypes.SeparatedByQuantity:
                ti = SeparateOrders(ticket, orderSelector).OrderBy(x => x.MenuItemName);
                break;

            default:
                ti = ticket.Orders.Where(orderSelector).OrderBy(x => x.Id).ToList();
                break;
            }
            return(ti);
        }
Exemple #19
0
        public void CanReportStatusInformation()
        {
            var printer        = CreateTestProbe();
            var printerMonitor = CreateTestProbe();

            var commands = new List <PrinterCommand>()
            {
                new PrinterCommand(1, "M104 S40"),
                new PrinterCommand(2, "M190")
            };

            var job = ActorOf(PrintJob.Props(commands, printer.Ref, printerMonitor.Ref));

            printerMonitor.ExpectMsg <PrintJobStatusUpdated>(cmd => cmd.State == PrintJobState.Ready);

            job.Tell(StartPrinting.Instance, TestActor);
            printerMonitor.ExpectMsg <PrintJobStatusUpdated>(cmd => cmd.State == PrintJobState.Running);
            printerMonitor.ExpectMsg <PrintJobStepsCompleted>(cmd => cmd.TotalSteps == 4 && cmd.StepsCompleted == 0);

            job.Tell(PrinterCommandProcessed.Instance, printer.Ref);
            printerMonitor.ExpectMsg <PrintJobStepsCompleted>(cmd => cmd.TotalSteps == 4 && cmd.StepsCompleted == 1);

            job.Tell(PrinterCommandProcessed.Instance, printer.Ref);
            printerMonitor.ExpectMsg <PrintJobStepsCompleted>(cmd => cmd.TotalSteps == 4 && cmd.StepsCompleted == 2);

            job.Tell(PrinterCommandProcessed.Instance, printer.Ref);
            printerMonitor.ExpectMsg <PrintJobStepsCompleted>(cmd => cmd.TotalSteps == 4 && cmd.StepsCompleted == 3);

            job.Tell(PrinterCommandProcessed.Instance, printer.Ref);
            printerMonitor.ExpectMsg <PrintJobStepsCompleted>(cmd => cmd.TotalSteps == 4 && cmd.StepsCompleted == 4);
            printerMonitor.ExpectMsg <PrintJobStatusUpdated>(cmd => cmd.State == PrintJobState.Completed);
        }
        /// <summary>
        /// Implementation of <see cref="IWorkflowScript.OnWorkflowScriptExecute" />.
        /// <seealso cref="IWorkflowScript" />
        /// </summary>
        /// <param name="app"></param>
        /// <param name="args"></param>
        public void OnWorkflowScriptExecute(Hyland.Unity.Application app, Hyland.Unity.WorkflowEventArgs args)
        {
            try
            {
                // Initialize global settings
                IntializeScript(ref app, ref args);

                List <Document> unityDocs = new List <Document>();
                unityDocs.Add(_currentDocument);

                PrintQueue printQueue = app.Core.PrintManagement.PrintQueues.Find(printQ);

                PrintRequestProperties printReqProp = app.Core.PrintManagement.CreatePrintRequestProperties(unityDocs, printQueue);

                PrintJob printJob = app.Core.PrintManagement.EnqueuePrintRequest(printReqProp);

                app.Diagnostics.Write("Print Job Sent");
            }
            catch (Exception ex)
            {
                // Handle exceptions and log to Diagnostics Console and document history
                HandleException(ex, ref app, ref args);
            }
            finally
            {
                // Log script execution end
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info,
                                        string.Format("End Script - [{0}]", ScriptName));
            }
        }
Exemple #21
0
        public IEnumerable <TicketPrintTask> GetPrintTasksForTicket(Ticket ticket, PrintJob printJob,
                                                                    Func <Order, bool> orderSelector)
        {
            var orders = GetOrders(printJob, ticket, orderSelector);

            return(GetPrintTasks(printJob, ticket, orders));
        }
Exemple #22
0
        public static void Run()
        {
            // Get the source PDF which has the attachments as byte data
            byte[] pdfArray = System.IO.File.ReadAllBytes(Util.GetPath("Resources/PdfWithAttachments.pdf"));

            // Create an InputPdf object using the PDF byte data
            InputPdf inputPdf = new InputPdf(pdfArray);

            // Loop through the attachments
            for (int i = 0; i < inputPdf.Attachments.Length; i++)
            {
                if (inputPdf.Attachments[i] != null)
                {
                    InputPdf attachedPdf = inputPdf.Attachments[i].TryGetPdf();
                    if (attachedPdf != null)
                    {
                        // Create a print job with the document to be printed to the default printer
                        PrintJob printJob = new PrintJob(Printer.Default, attachedPdf);

                        // Print the print job
                        printJob.Print();
                    }
                }
            }
        }
Exemple #23
0
 public void ManualPrintTicket(Ticket ticket, PrintJob printer)
 {
     AppServices.MainDataContext.UpdateTicketNumber(ticket);
     if (printer != null)
     {
         TicketPrinter.ManualPrintTicket(ticket, printer);
     }
 }
Exemple #24
0
            public PrintStatus OnPrint(PrintJob printJob)
            {
                PrintSettings printSettings = func(printJob.PrintSettings);

                printSettings.PrintBackgrounds = true;
                printSettings.PageMargins      = new PageMargins(20, 40, 40, 20);
                return(PrintStatus.CONTINUE);
            }
        public static void Run()
        {
            // Create a print job with the document to be printed to the default printer
            PrintJob printJob = new PrintJob(Printer.Default, Util.GetPath("Resources/DocumentA.pdf"));

            // Print the print job
            printJob.Print();
        }
Exemple #26
0
        public ActionResult DeleteConfirmed(int id)
        {
            PrintJob printjob = db.PrintJobs.Find(id);

            db.PrintJobs.Remove(printjob);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #27
0
 public frmPrintPreview(PrintJob prj, frmStudioMain mainForm)
 {
     this.PrintJob     = prj;
     this.GLCONTROL    = frmStudioMain.SceneControl;
     this._plWorkspace = mainForm.plWorkSpace;
     GenerateThumbnails(null, null);
     UpdatePrintTimeStamp();
 }
        private void InternalPrint(Ticket ticket, PrintJob printJob, Func <Order, bool> orderSelector)
        {
            var tasks = _ticketPrintTaskBuilder.GetPrintTasksForTicket(ticket, printJob, orderSelector);

            foreach (var ticketPrintTask in tasks.Where(x => x != null && x.Printer != null && x.Lines != null))
            {
                PrintJobFactory.CreatePrintJob(ticketPrintTask.Printer, _printerService).DoPrint(ticketPrintTask.Lines);
            }
        }
Exemple #29
0
 public void PrintTicket(Ticket ticket, PrintJob customPrinter)
 {
     Debug.Assert(!string.IsNullOrEmpty(ticket.TicketNumber));
     if (customPrinter.LocksTicket)
     {
         ticket.RequestLock();
     }
     PrintOrders(customPrinter, ticket);
 }
Exemple #30
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            ThermalLabel _currentThermalLabel = null;

            _currentThermalLabel = this.GenerateBasicThermalLabel();

            //Neodynamic.SDK.Printing.PrinterSettings _printerSettings = new Neodynamic.SDK.Printing.PrinterSettings();
            Neodynamic.SDK.Printing.PrinterSettings _printerSettings = new Neodynamic.SDK.Printing.PrinterSettings();
            _printerSettings.Communication.CommunicationType = CommunicationType.USB;
            _printerSettings.PrinterName         = _Printer;
            _printerSettings.Dpi                 = 203;
            _printerSettings.ProgrammingLanguage = (ProgrammingLanguage)Enum.Parse(typeof(ProgrammingLanguage), "ZPL");
            PrintOrientation _printOrientation = PrintOrientation.Portrait;

            int    x = 0;
            bool   isPrinterValid = false;
            string printerName    = _Printer;
            string query          = string.Format("SELECT * from Win32_Printer "
                                                  + "WHERE Name LIKE '%{0}'",
                                                  printerName);

            ManagementObjectSearcher   searcher = new ManagementObjectSearcher(query);
            ManagementObjectCollection coll     = searcher.Get();

            foreach (ManagementObject printer in coll)
            {
                foreach (PropertyData property in printer.Properties)
                {
                    //Console.WriteLine(string.Format("{0}: {1}",
                    //                                property.Name,
                    //                                property.Value));
                    if (x == 85)
                    {
                        isPrinterValid = (bool)property.Value;
                    }
                    x++;
                }
            }

            if (isPrinterValid)
            {
                MessageBox.Show("Impresora no conectada o apagada. Asegúrese de que la impresora esté conectada y que esté encendida. \nPuede imprimir la etiqueta en otro momento en el menú ACTUALIZAR.", "Conecte y encieda la impresora", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                for (int i = 0; i < 2; i++)
                {
                    using (PrintJob pj = new PrintJob(_printerSettings))
                    {
                        pj.PrintOrientation = _printOrientation;
                        pj.ThermalLabel     = _currentThermalLabel;
                        pj.Print();
                    }
                }
                this.Close();
            }
        }
 public void PrintJob(PrintJob job)
 {
     if (!this.Initialized)
     {
         this.Initialize();
     }
     StartDocument();
     Stream renderedDocument = RenderDocument(job);
     WriteDocumentToDevice(renderedDocument);
     EndDocument();
 }
Exemple #32
0
        static void Main(string[] args)
        {
            var stopwatch = new System.Diagnostics.Stopwatch();
            stopwatch.Start();

            var printJob = new PrintJob("DICOM PRINT JOB")
            {
                RemoteAddress = "localhost",
                RemotePort = 8000,
                CallingAE = "PRINTSCU",
                CalledAE = "PRINTSCP"
            };

            printJob.StartFilmBox("STANDARD\\1,1", "PORTRAIT", "A4");

            printJob.FilmSession.IsColor = false; //set to true to print in color
            
            //greyscale
            var dicomImage = new DicomImage(@"Data\1.3.51.5155.1353.20020423.1100947.1.0.0.dcm");
            
            //color
            //var dicomImage = new DicomImage(@"Data\US-RGB-8-epicard.dcm");
            
            var bitmap = dicomImage.RenderImage() as System.Drawing.Bitmap;
            
            printJob.AddImage(bitmap, 0);
            
            bitmap.Dispose();

            printJob.EndFilmBox();

            printJob.Print();

            stopwatch.Stop();
            Console.WriteLine();
            Console.WriteLine(stopwatch.Elapsed);

        }
Exemple #33
0
        public DicomNActionResponse OnNActionRequest(DicomNActionRequest request)
        {
            if (_filmSession == null)
            {
                Logger.Error("A basic film session does not exist for this association {0}", CallingAE);
                return new DicomNActionResponse(request, DicomStatus.InvalidObjectInstance);
            }

            lock (_synchRoot)
            {
                try
                {

                    var filmBoxList = new List<FilmBox>();
                    if (request.SOPClassUID == DicomUID.BasicFilmSessionSOPClass && request.ActionTypeID == 0x0001)
                    {
                        Logger.Info("Creating new print job for film session {0}", _filmSession.SOPInstanceUID.UID);
                        filmBoxList.AddRange(_filmSession.BasicFilmBoxes);
                    }
                    else if (request.SOPClassUID == DicomUID.BasicFilmBoxSOPClass && request.ActionTypeID == 0x0001)
                    {
                        Logger.Info("Creating new print job for film box {0}", request.SOPInstanceUID.UID);

                        var filmBox = _filmSession.FindFilmBox(request.SOPInstanceUID);
                        if (filmBox != null)
                        {
                            filmBoxList.Add(filmBox);
                        }
                        else
                        {
                            Logger.Error("Received N-ACTION request for invalid film box {0} from {1}", request.SOPInstanceUID.UID, CallingAE);
                            return new DicomNActionResponse(request, DicomStatus.NoSuchObjectInstance);
                        }
                    }
                    else
                    {
                        if (request.ActionTypeID != 0x0001)
                        {
                            Logger.Error("Received N-ACTION request for invalid action type {0} from {1}", request.ActionTypeID, CallingAE);
                            return new DicomNActionResponse(request, DicomStatus.NoSuchActionType);
                        }
                        Logger.Error("Received N-ACTION request for invalid SOP class {0} from {1}", request.SOPClassUID, CallingAE);
                        return new DicomNActionResponse(request, DicomStatus.NoSuchSOPClass);
                    }

                    var printJob = new PrintJob(null, Printer, CallingAE, Logger, _filmSession)
                    {
                        SendNEventReport = _sendEventReports
                    };
                    printJob.StatusUpdate += OnPrintJobStatusUpdate;

                    printJob.Print(filmBoxList, SaveJob);

                    if (printJob.Error == null)
                    {

                        var result = new DicomDataset
                        {
                            new DicomSequence(new DicomTag(0x2100, 0x0500),
                                new DicomDataset(new DicomUniqueIdentifier(DicomTag.ReferencedSOPClassUID,
                                    DicomUID.PrintJobSOPClass)),
                                new DicomDataset(new DicomUniqueIdentifier(DicomTag.ReferencedSOPInstanceUID,
                                    printJob.SOPInstanceUID)))
                        };

                        var response = new DicomNActionResponse(request, DicomStatus.Success);
                        response.Command.Add(DicomTag.AffectedSOPInstanceUID, printJob.SOPInstanceUID);
                        response.Dataset = result;

                        return response;
                    }
                    throw printJob.Error;
                }
                catch (Exception ex)
                {
                    Logger.Error("Error occured during N-ACTION {0} for SOP class {1} and instance {2}",
                        request.ActionTypeID, request.SOPClassUID.UID, request.SOPInstanceUID.UID);
                    Logger.Error(ex.Message);
                    return new DicomNActionResponse(request, DicomStatus.ProcessingFailure);
                }
            }
        }
 public PrintWrapper()
 {
     marginx = 50;
     marginy = 50;
     job = new PrintJob (PrintConfig.Default ());
     job.GetPageSize (out page_width,
              out page_height);
     width = page_width - marginx - marginx;
     height = page_height - marginy - marginy;
     tags = new ArrayList ();
     tab_string = "        ";
     font = Font.
         FindClosestFromWeightSlant
         ("monospace", FontWeight.Regular,
          false, 8);
     line_space_ratio = 1.8;
 }
 protected abstract void PrintJob(PrintJob job);
 private Stream RenderDocument(PrintJob job)
 {
     //device specific code
     return null;
 }
 public void PrintJob(PrintJob job)
 {
     this.device.PrintJob(job);
 }
 protected override Stream RenderDocument(PrintJob job)
 {
     //device specific code
     return null;
 }
Exemple #39
0
        private void button2_Click(object sender, EventArgs e)
        {
            string printername = "";
            PrintDialog pd = new PrintDialog();
            if (pd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                printername = pd.PrinterSettings.PrinterName;
                try
                {
                    HtmlToPdfConverter htmlToPdfConverter = new HtmlToPdfConverter();
                    htmlToPdfConverter.LicenseKey = "sjwvPS4uPSskPSgzLT0uLDMsLzMkJCQk";
                    htmlToPdfConverter.HtmlViewerWidth = 850;
                    htmlToPdfConverter.PdfDocumentOptions.AvoidImageBreak = true;

                    byte[] outPdfBuffer = htmlToPdfConverter.ConvertHtml(winFormHtmlEditor1.DocumentHtml, "");

                    InputPdf inputPdf = new InputPdf(outPdfBuffer);
                    //PrinterSettings settings = new PrinterSettings();
                    PrintJob printJob = new PrintJob(printername, inputPdf);
                    printJob.DocumentName = ReportCombo.Text.Replace(" ", "_").Replace("/","");
                    PrintJob.AddLicense("FPM20NXDLB2DHPnggbYuVwkquSU3u2ffoA/Pgph4rjG5wiNCxO8yEfbLf2j90rZw1J3VJQF2tsniVvl5CxYka6SmZX4ak6keSsOg");
                    printJob.PrintOptions.Scaling = new AutoPageScaling();
                    printJob.Print();
                }
                catch (Exception ee)
                {
                    Logger.Instance.WriteToLog(ee.ToString());
                }
            }
        }
Exemple #40
0
        public static void Print(string html_string, string printername)
        {
            try
            {
                string body = "";
                HtmlToPdfConverter converter = GetInitializedHtmlConverter(html_string, out body);
                byte[] outPdfBuffer = converter.ConvertHtml(body, "");

                InputPdf inputPdf = new InputPdf(outPdfBuffer);

                //PrinterSettings settings = new PrinterSettings();
                PrintJob printJob = new PrintJob(printername, inputPdf);
                PrintJob.AddLicense("FPM20NXDLB2DHPnggbYuVwkquSU3u2ffoA/Pgph4rjG5wiNCxO8yEfbLf2j90rZw1J3VJQF2tsniVvl5CxYka6SmZX4ak6keSsOg");
                printJob.PrintOptions.Scaling = new AutoPageScaling();
                printJob.Print();
            }
            catch (Exception ee)
            {
                Logger.Instance.WriteToLog(ee.ToString());
            }
        }
 protected abstract Stream RenderDocument(PrintJob job);