Bulk Print Invoices/Shipping Labels?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
10 years ago
Is there a way to bulk print invoices instead of going to each order, opening up each PDF and printing it out?

Also, is there an easy way for printing Shipping Labels?

Any help is appreciated!
10 years ago
i would like to know this as wel.
Thanks!
10 years ago
I think is not possible without doing coding or writing plugin.

But if you able to modify code to get collection of invoices as byte[] you can use iTextSharp library to merge generated invoices.
you can write simple plugin for that and invoke action with jQuery.


        
        public ActionResult PrintInvoices(string selectedIds)
        {
            int[] orderIds = null;
            if (selectedIds != null)
            {
                var ids = selectedIds
                    .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                    .Select(x => Convert.ToInt32(x))
                    .ToArray();
                orderIds = ids;
            }

            if (orderIds != null && !String.IsNullOrEmpty(selectedIds))
            {
                var invoicesStream = new List<byte[]>();


                foreach (var orderId in orderIds.AsParallel().WithDegreeOfParallelism(4))
                {
                    invoicesStream.Add(GetInvoice(orderId));
                }

                byte[] invoicesReady = MergeInvoices(invoicesStream);

                foreach (var orderId in orderIds.AsParallel().WithDegreeOfParallelism(4))
                {
                    var order = _orderService.GetOrderById(orderId);
                    order.OrderStatus = OrderStatus.Processing;
                    _orderService.UpdateOrder(order);
                }

                return File(invoicesReady, "application/pdf", "Invoices.pdf");
            }
            else
            {
                ///TODO define in resources
                ErrorNotification("Orders not selected for printing", true);
                return RedirectToAction("List", "Order", new { area = "Admin" });
            }
        }

        private byte[] MergeInvoices(List<byte[]> invoiceBytes)
        {
            PdfMerge merge = new PdfMerge();
            foreach (var content in invoiceBytes)
            {
                merge.AddDocument(content);
            }
            MemoryStream stream = new MemoryStream();
            merge.Merge(stream);
            var result = stream.ToArray();
            stream.Close();
            return result;
        }

      private byte[] GetInvoice(int orderId)
      {
           here is your invoice generation code
      }


But on the list.cshtml for orders you can put the next jQuery

 $('#printInvoices').click(function (e) {
                e.preventDefault();
                //redirect to required URL
                setLocation('@(Url.Action("PrintInvoices", "Invoicing", new { area = ""}))?selectedIds=' + selectedIds.join(","));
                return false;
            });


The rest of depend on your imagination. For example i printing all the pending invoices
10 years ago
Hmm, was struggling with this problem for a few days.
Then I decided to extend my plug-in so it is possible to export invoices and packagingslips between a picked period of time and at customer if wanted.
The existing functions in the PDFService class, do allow multiple orders or shipments to be inserted. Now only one is send to both functions, it is simple to just add a button and dropdownlist with users, which retrieves the orders you need at customerid.
Then just send the orders to the function, the foreach loop: foreach(var order in orders) already exists and it will work.

Ask me if you want me to provide you some code.
9 years ago
hellow, could you provide some code for multiple printing?
regards
9 years ago
Has this ever been updated or fixed.  With the christmas season my guys are spending a very long time printing these out one by one,  a few hundred orders a day is costing me money to pay someone..

Anyone have a plugin for sale or an alternate method that could be easily implemented? I'm not much of a programmer and our developers are tied up on other projects.
9 years ago
What version of Nop are you using?

This feature became available on 3.3 where you can check the boxes of multiple orders and click Print (selected) and it makes a PDF of all of them.
9 years ago
Awesome! THANKS!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.