Send Documents to Printers

Hi All,

There is an nice function in Acumatica 2018R1 – Device Hub. This service can be installed on any machine where printer is configured/available and automatically pull Acumatica for documents need to be printed.
There are a lot of screens who uses this function in the standard Acumatica already, but today I want to give you a quick look on how you can write your custom code and send request to printers.

Device Hub
First of All device hub should be installed on your computer, connected to Acumatica and configured with Available printers.
Acumatica Device Hub
Printers also should be Configured in Acumatica.
Acumatica Printers

Customization
Now we can write a bit of code. I’ll create a button on Invoice and Memos screen where I can print 2 documents in unattended more using 2 printers I have created.
Actually all work for printing documents is done thought PX.SM.SMPrintJobMaint and you can pass there name of the report and parameters the same way how you throw PXReportRequiredException. Just call CreatePrintJob method and pass there required data.

namespace PX.Objects.AR
{
  public class ARInvoiceEntry_Extension : PXGraphExtension<ARInvoiceEntry>
  {
    #region Event Handlers
    public PXAction<PX.Objects.AR.ARInvoice> Printer;
  
    [PXButton(CommitChanges = true)]
    [PXUIField(DisplayName = "Printer")]
    protected void printer()
    {
      ARInvoice invoice = Base.Document.Current;
      Dictionary<string, string> printParams = new Dictionary<string, string>();
      printParams["ARInvoice.DocType"] = invoice.DocType;
      printParams["ARInvoice.RefNbr"] = invoice.RefNbr;

      PXReportRequiredException ex = null;
      ex = PXReportRequiredException.CombineReport(ex, "AR641000", printParams);

      PX.SM.SMPrintJobMaint.CreatePrintJobGroup("PRINTER1", ex, "Report 1"); //Job1
      PX.SM.SMPrintJobMaint.CreatePrintJobGroup("PRINTER2", ex, "Report 2"); //Job2
      
    }
    #endregion
  }
}

Now if you click the button on the screen, you can see how job is send to the printers:
Acumatica Printers Jobs
Hope it helps and have a nice day!

1 Reply to “Send Documents to Printers”

  1. Hi Sergey,

    Thanks so much for helping me resolve this. If it was not for this post and your fast and accurate assistance we would have had a serious problem with the current implementation i am busy with. This is an awesome solution and it runs like clockwork. You saved the client from spending a fortune on 3rd party solutions.

Leave a Reply

Please rate*

Your email address will not be published. Required fields are marked *