+49 541 9493-0  Kontakt  

SNC Print

The SNC Print solution makes it possible to print documents and receipts directly from the Business Central cloud instance to local printers. This documentation provides support for setting up and using the solution.

Note
This document is for information purposes only. If used for other purposes, SIEVERS-SNC Computer & Software GmbH & Co. KG disclaims all warranties for defects in title and quality. SIEVERS-SNC Computer & Software GmbH & Co. KG disclaims all liability for direct and indirect damages - whether in contract or in law - arising out of or in connection with the use of this manual. This manual is subject to change without notice by SIEVERS-SNC Computer & Software GmbH & Co. KG without prior notice. The programs described may only be used or copied in accordance with the terms of the license. This document has been prepared for the support of end users, sales and service as well as developers and may be given to this group of persons without any changes. Copyright notice
Copyright © 2024 SIEVERS-SNC Computer & Software GmbH & Co. KG, a company of the SIEVERS-GROUP, Hans-Wunderlich Str.8, D-49078 Osnabrück, Germany. Microsoft, Microsoft Azure, Microsoft Dynamics and Business Central are registered trademarks. All rights not expressly granted are reserved. Published by SIEVERS-SNC Computer & Software GmbH & Co. KG.

1 Introduction

With SNC Print, you are able to control local printers and print documents from a Business Central SaaS environment. The solution works with a service running locally on Windows, which receives the print jobs from Business Central and routes them to the printer via dispatcher software. Examples of dispatcher software include Adobe Acrobat Reader, Sumatra PDF or Command Line Print.

The setup takes place on different levels. On the one hand, the extension itself must be set up in Business Central. You can find a description in the section Setup in BC using the setup wizard. In addition, a setup of the said service must take place. If the Business Central system is located in a cloud environment, this service must also be registered in the Azure Portal. More information on this can be found in the section Service setup.

2 Setup in BC using the Setup Wizard

SNC Print offers the option of setup via the setup wizard. This allows the relevant settings to be made without any detours.

The first step is to set up the printer’s paper trays.

In this overview you enter the paper formats you use.

Here are the these fields:

After you have entered the paper formats, you can create virtual printers in the next step. To do this, open the (still) empty overview.

The solution now knows your printers and their paper trays. Now it still needs to know what data to pass to the printers. For this reason, the next step is to assign the virtual printers just created to the reports to be printed and to a user.

The last step is to set up deletion automation. This is used to avoid print jobs that have already been delivered. When you click Delete Print Jobs Setup in the Setup Wizard, a delete job is automatically created and started in BC Standard. It is configured to remove print jobs after 60 minutes. If you want to edit it, you must first stop it with the Set to Wait operation.

The setup of SNC Print on Business Central is now complete. At last, you will be shown some data that is necessary for further setup.

The SNC Print Service must now be set up to process the print jobs from Business Central.

3 Service Setup

Depending on which Business Central system is involved, more or fewer setup steps have to be performed. This is because the service cannot simply access a Business Central system in the cloud. Preparations are required for this, such as registering the service in the Azure Portal. If it is a cloud system, all the following setup steps are necessary:

  1. Set up the ME application in Azure Portal
  2. Enable ME application in Business Central
  3. Create and configure service on prem

In the case of an on prem system, you only need to perform step 3.

3.1 Set up the ME application in Azure Portal

To use the service with a Business Central SaaS, it must be registered and set up on Azure beforehand.

To do this, open the portal.azure.com page and log in with the correct tenant. In the menu you will find the item Microsoft Entra ID.

Here you can register new apps in the App registrations section. Create a new app registration with New registration.

Give the app a name, for example SNC Print Service. Also make sure that in the Supported account types section, the first option Accounts in this organizational directory only is selected. Now click on ‘Register’.

After registration, some important data is displayed. Save the Application ID and the Directory/Tenant ID separately. You will need them later. Then add a Client Secret with Add a certificate or secret. This is necessary for the creation of credentials.

Click on New client secret

You can enter any name for the description. Then add a date on which the secret should expire.

Attention

After you have created the Secret, you must copy the Secret-Value immediately and save it separately. Copying is only possible when the value is displayed for the first time.

Then switch to the API Permissions menu.

In the API Permissions, the service must now be authorized to receive data from the Business Central API. To do this, add a new permission with Add a permission.

Then you need to select for which API you want to assign the permission.

Now the authorization is configured. It is an application authorization. In addition, the service should be able to read as well as write. Therefore set the permissions as shown in the following screenshot.

After you save the permission, the permission still needs to be granted admin consent. To do this, select Grant admin consent for Contoso.

Now only the authentication of the service must be enabled. To do this, open the Authentication page via the menu.

Add a Mobile and desktop applications configuration via Add platform.

In this configuration, set up the redirect URI to

https://businesscentral.dynamics.com/OAuthLanding.htm

Set the Allow public client flows option to Yes.

The Business Central tenant is now ready to use the SNC Print Service.

3.2 Enable ME Application in Business Central

In Business Central, open the Microsoft Entra Applications page and create a new client.

At this point, an ID that you created when setting up the service in Azure comes into play. Enter the client ID in the first field, add a description and switch the State to enabled.

Then assign the user permission sets D365 FULL ACCESS and SNC PRINT to the service.

3.3 Create and configure service on prem

To send the print jobs from BC to the printer, the transfer by a computer is necessary. The SNCPrint service supplied must be running on this computer. The next sections describe how to set this up.

3.3.1 Credentials

Hinweis

If you are using SNC Print in an OnPremise environment, ensure that you connect to a Service Tier which is set up with NavUserPassword authentication. The SNCPrintService is not able to connect via Windows authentication.

To retrieve print jobs from Business Central, credentials must be stored on the service. Various commands are available for managing the credentials:

Hint

Make sure that you are in the same file as the SNCPrintService.exe!

To do this, call the following command to create a new credential:

SNCPrintService.exe credentials

After that, enter the following data:

Attention

If you intend to run the service as a Windows service, you must enter the credentials with the same user who will ultimately run the Windows service.

Here you can find the Web Service Access Key
The necessary data at the end of the setup wizard

3.3.2 Appsettings

In the included SNCPrintService you will find an appsettings.json file.

Example configuration of the appsettings.json

API

LocalStorage

Sources

The print jobs can come from several sources. These sources are companies, i.e. the respective BC instances. Several companies can be stored in this area.

Printing

Dispatcher

3.4 Dispatcher

The dispatcher is used to transfer the print job to the printer. This can be any PDF printing software. For example, Adobe Acrobat Reader or SumatraPDF would be possible. This software must be stored in the /external/ directory of the service. In order to submit the print job correctly, a script is required for the execution of the dispatcher. The following example script has been created using the SumatraPDF dispatcher:

Param(
    # UNC-Pfad des Druckers
    [Parameter(Mandatory = $True)]
    [string]$Path,
    # Pfad der zu druckenden PDF-Datei
    [Parameter(Mandatory = $True)]
    [string]$Printer,
    # Pfad zur Metadaten JSON-Datei
    [string]$Metadata
)
..\extern\SumatraPDF-3.4.6-64.exe -print-settings duplex -print-to "$Printer" "$Path"

You can also find such an example script in the /bin/ directory of the service.

3.5 Create Windows background service

To avoid having to start the service manually every time you restart Windows, you can create a Windows background service.

First create the service via Powershell with the following command. The access data of the user under whose name the service is to be executed will be requested:

.\New-SNCPrintService.ps1

Then open Services on your Windows system. Here you should find the service you just created under the name SNC Print Service. Double click to open the dialog associated with this service. There you can start the service.

If everything worked, you will find the successful execution of the service in the Windows Event Viewer in the Applications section of the Windows logs.

If the execution was successful, you can set the startup type to Automatic in the General tab of the service.

4 Using SNC Print

Before SNC Print can be used, the service must be started. For the first test operation, it is useful to be able to read as detailed a log as possible. To do this, call the following command in a command prompt:

.\bin\SNCPrintService.exe -c .\appsettings.json --loglevel Debug
Note

You can run the SNCPrintService like any other service on Windows automatically at system startup. Please note that in this case the credentials must be stored by the same user who runs the Windows service.

If there are no error messages, you can test the service.

Printing with SNC Print is no different from printing in BC Standard. Once set up, reports assigned to the printer can be easily printed. The print job is transferred to the storage directory of the service along with metadata after clicking Print.

The folder of a print job
The content of the print job

Afterwards, Dispatcher automatically transfers the data to the printer stored in appsettings.json.