# Print Server Configuration

## Introduction

This manual describes the configuration of the server-side components of the application *GBS Print*.

The configuration procedure must be performed only after the installation step. For more information, consult the [GBS Apps Installation Manual](https://docs.griaule.com/gbs/en/web-components/gbsappssetup).

## Configuration

The steps for configuration are:

1. [Configure Tomcat](#configuracao-do-tomcat);
2. [Configure the certificates](#configuracao-de-certificados);
3. [Generate the encrypted password](#criptografia-da-senha-do-banco-de-dados);
4. [Configure other properties in the config.properties file](#arquivo-de-configuracao-da-aplicacao);
5. [Install and configure the printing systems](#sistemas-de-impressao);
6. [Install the fonts](#instalacao-de-fontes);

All steps are described below. An example of the file `config.properties` can be found in the section [Configuration File Example](#exemplo-do-arquivo-de-configuracao).

{% hint style="danger" %}
All lines must be present in the configuration file. Commenting out or deleting lines may cause unexpected behavior. For additional information, contact the Griaule Support Team.
{% endhint %}

### Tomcat Configuration

Edit Tomcat's configuration file to configure the certificates and the port the application will use.

```sh
vi /var/lib/tomcats/print/conf/server.xml
```

To change the port, search for `Connector port=`. This is the port for backend operations.

The default port of GBS Print is `8127`.

### Certificates Configuration

To enable SSL authentication, search for `Connector port=` in the file `/conf/server.xml`.

There are several entries. Look for the one that defines a *SSL HTTP/1.1 Connector*. If necessary, remove the comment delimiters `<!--` and `-->`. Then, adjust the following settings:

```properties
port="58194"
keystoreFile="/home/griaule/keystore"
keystorePass="password"
keyAlias="1"
clientAuth="true"
truststoreFile="/home/griaule/keystore"
truststorePass="password"
```

The parameter `port` must be the desired network port for the application.

Change the path of `keystoreFile` and `truststoreFile` to the correct values. Do the same for `keystorePass` and `truststorePass`.

The parameter `clientAuth="true"` will require server authentication to the client and client authentication to the server. This means the client will need to import the certificate into the browser to be able to access the application.

{% hint style="warning" %}
When `clientAuth` is set to `true`, the system administrator must provide the file `certificate.pfx` to end users.
{% endhint %}

### Database Password Encryption

In the file `config.properties`, the parameter `jdbc.password` is an encrypted password. To generate the encrypted password, follow the steps below:

1. Go to the following directory:

   ```sh
   cd /var/lib/tomcats/print/webapps/gbs-print-server/WEB-INF/lib
   ```
2. Run the command:

   ```sh
   java -cp gbs-common-db-<version>.jar com.griaule.commons.util.EncryptUtil <desiredPassword>
   ```
3. The encrypted password will appear after the message: *"Encrypted password is:"*

{% hint style="info" %}
Save the encrypted password. It will be used in the next step.
{% endhint %}

### Application Configuration File

To configure the file, open it with:

```sh
vi /var/lib/tomcats/print/conf/config.properties
```

The most important changes in this file are the parameters `jdbc.url`, `jdbc.username`, `jdbc.password` and `gbds.url`. Configure them according to your environment.

The complete configuration file is shown in the section [Configuration File Example](#exemplo-do-arquivo-de-configuracao).

{% hint style="info" %}
Remember to replace the encrypted password generated in the section [Database Password Encryption](#criptografia-da-senha-do-banco-de-dados) in this file.
{% endhint %}

#### Print Settings

The last step is to configure the IP and port of the application that the end user will access. It must be the same IP and port configured in the section [Tomcat Configuration](#configuracao-do-tomcat).

```properties
print.ip=<ip>
print.port=<port>
print.protocol=<protocol>
```

{% hint style="warning" %}
Make sure the configuration parameters `print.ip`, `print.port` and `print.protocol` are correctly specified in the file `config.properties`. In many cases, the IP will be the same for several applications. However, each application will have a **different and unique port**.
{% endhint %}

{% hint style="warning" %}
Make sure the configuration parameter `resizeFloat=0.3` be present in the configuration file (`config.properties`). It determines the percentage of compression of the document image to be saved in the database at the end of the process. The default value is `0.3` (30% compression).
{% endhint %}

### Printing Systems

#### CUPS Installation

The *Common UNIX Printing System (CUPS)* is a printing system for UNIX-based operating systems. It allows a computer to act as a print server, receiving print jobs from client computers and sending them to the appropriate printer. To install CUPS, follow these steps:

Install CUPS:

```sh
sudo yum install cups -y
```

Enable and start the CUPS service:

```sh
sudo systemctl enable cups
sudo systemctl start cups
```

Then, install the graphical interface for CUPS:

```sh
sudo yum install system-config-printer -y
```

{% hint style="success" %}
If the install command fails, try cleaning the *yum*:

```sh
sudo yum clean all
```

{% endhint %}

#### CUPS Configuration

To configure CUPS, edit the configuration file:

```sh
sudo vim /etc/cups/cupsd.conf
```

To allow access from other computers to the CUPS server, change the following line from:

```properties
Listen localhost:631
```

To:

```properties
Listen 0.0.0.0:631
```

Then, to allow access to the server, add the permission `Allow from all` address to `<Location />`. To do this, look for the following lines and change them as follows:

```apacheconf
# Restrict access to the server...
<Location />
   Order allow,deny
   Allow from all
</Location>
```

Also, to allow access to the administration pages, add the permission `Allow from all` address to `<Location /admin>`. To do this, look for the following lines and change them as follows:

```apacheconf
# Restrict access to the admin pages...
<Location /admin>
   Order allow,deny
   Allow from all
</Location>
```

Then, save and close the configuration file.

Finally, to apply the changes, restart the CUPS service:

```sh
sudo systemctl restart cups
```

#### HPLIP Installation (HP Printer Drivers)

The *HP Linux Imaging and Printing (HPLIP)* is a free and open-source solution developed by HP for printing on Linux using HP printers. To install HPLIP, run:

```sh
sudo yum install hplip -y
```

Then, create a group for printer administration:

```sh
sudo groupadd lpadmin
```

Finally, add the user `root` to the group `lpadmin`:

```sh
sudo usermod -a -G lpadmin root
```

#### Printer Configuration

First, start the network printer discovery service by running:

```sh
sudo systemctl enable cups-browsed.service
sudo systemctl start cups-browsed.service
sudo systemctl status cups-browsed.service
```

Next, access the CUPS web interface at `http://<server_ip>:631` using a browser.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-ba00f0f2ac355d078e2d0fb3afc0e187dae067c1%2Fcups_web_gui.png?alt=media)

In the top menu, click the `Administration` tab and then the Add Printer button.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-2c0ae46fa33f4eb5add87a822ea5dd8bf19cdfd6%2Fcups_administration_tab.png?alt=media)

If a message appears saying an update is required, click the displayed URL, then the Advanced button and `Proceed to https://<server_ip>:631 (unsafe)`.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-6f027f6891a38e9ba690617f4886556c64279bda%2Fcups_upgrade_required.png?alt=media)

When returning to the CUPS web interface, click the Add Printer button again and, if prompted, log in with the user credentials `root` of the server.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-0b5d21d7012f8bb97636885134f903b5400b7c2c%2Fcups_sign_in.png?alt=media)

On the **Add Printer**page, in the **Local Printers**section, select `HP Printer (HPLIP)` and click the Continue button.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-7dab04acf5d1e869489780043d7a31c09ff93e47%2Fcups_add_printer_page.png?alt=media)

Then, in the **Connection**, enter `socket://<printer_IP>` and click the Continue button.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-a0a0903955c3f47b7f1359020395e533c5e36bf8%2Fcups_add_printer_connection.png?alt=media)

Then, enter a `Name`, `Description` and `Location` for the printer, following the instructions on the page for each field, and click the Continue button.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-9483e696b319673c61700f8d06aedd351039db40%2Fcups_add_printer_details.png?alt=media)

In the **Make**select the printer manufacturer and click the Continue button.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-3b1882a3a3151f63882f06b5d7a1f8318607a58a%2Fcups_add_printer_make.png?alt=media)

Then, in the **Model**select the printer model from the list and click the Add Printer button.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-4ef6056abc197f0ae349677110bcbb48a0efaa3f%2Fcups_add_printer_model.png?alt=media)

Then, check the printer default settings and make sure they fit the environment.

{% hint style="success" %}
Be sure to select the correct paper size in the **General / Media Size**.
{% endhint %}

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-4301a2b34916e28a60838cb9801624dc71561717%2Fcups_printer_default_options.png?alt=media)

section.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-a2c82f4a09cbb47da714549a52ebef1119fb9ec7%2Fcups_printer_added.png?alt=media)

#### Finally, click the Set Default Options button to save the printer settings. If everything works as expected, a message will appear saying the printer was added successfully and you will be redirected to the printer page.

CUPS PDF (optional)

CUPS PDF provides a way to print to a PDF file. It is recommended for testing purposes.

```sh
To install CUPS PDF, run:
```

sudo yum install cups-pdf -y `The default path to save PDF files is`/root

. To change the path, edit the CUPS PDF configuration file:

```sh
Then, edit the CUPS PDF configuration file:
```

Under `vim /etc/cups/cups-pdf.conf`Path Settings `, change the parameter` Out \<path>

Next, access the CUPS web interface at `http://<server_ip>:631` using a browser.

In the top menu, click the `Administration` tab and then the Add Printer button.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-2c0ae46fa33f4eb5add87a822ea5dd8bf19cdfd6%2Fcups_administration_tab.png?alt=media)

On the **Add Printer**page, in the **Local Printers**section, select `to the desired path.` and click the Continue button.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-ac6e907a4d266e20f1ca3d234cb6738e95b047bd%2Fcups_add_cups_pdf_printer.png?alt=media)

Then, enter a `Name`, `Description` and `Location` for the printer, following the instructions on the page for each field, and click the Continue button.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-2772c2c6f475f83a9ec8ad191427fb4d1bca22cd%2Fcups_add_virtual_printer_details.png?alt=media)

Then, in the **CUPS-PDF (Virtual PDF Printer)**&#x4F;r Provide a PPD File `, click the Choose File button and select the file`Cups-PDF.ppd `. That` .ppd `file can be found in the directory` /etc/cups/ppd/

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-b1b8d36109fb66eb5ed74bf970537470bf143d2d%2Fcups_add_virtual_printer_ppd.png?alt=media)

on the server where CUPS PDF is installed. Then, click the Add Printer button.

{% hint style="success" %}
Be sure to select the correct paper size in the **General / Media Size**.
{% endhint %}

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-22a6c3339cfdb0cbcbf7dddb6566090d35018152%2Fcups_virtual_printer_default_options.png?alt=media)

section.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-91f3d3f94fd1a4ce996cc08937d7a137d49d5ed1%2Fcups_virtual_printer_added.png?alt=media)

### Check the printer default settings and make sure they fit the environment.

Font Installation `The application uses three fonts that must be installed:`, `Arial` and `OCR-B-10 BT`.

#### The application uses three fonts that must be installed:

Tahoma Bold

```sh
First, check if the font is already installed:
```

fc-list | grep arial

```sh
If the font is not installed (empty result), download the font:
```

wget <http://www.itzgeek.com/msttcore-fonts-2.0-3.noarch.rpm>

```sh
Then, install it:
```

rpm -Uvh msttcore-fonts-2.0-3.noarch.rpm

```sh
First, check if the font is already installed:
```

Check if the font was installed successfully: `.rpm files` You can then remove the

```sh
downloaded file:
```

#### Arial

rm msttcore-fonts-2.0-3.noarch.rpm *root*.

First, make sure you are logged in as

```sh
Then, check if the font is already installed:
```

fc-list | grep ocr `If the font is not installed (empty result), create a directory` in `ocrb`:

```sh
/usr/share/fonts/
```

{% hint style="warning" %}
mkdir /usr/share/fonts/ocrb `For the following steps, you must have the` .ttf `Arial`font file
{% endhint %}

. Download it from a trusted source or copy it from another machine. `Transfer the font file to the server and move it to the directory`.

/usr/share/fonts/ocrb

```sh
Then run:
```

fc-cache -f /usr/share/fonts/

```sh
Then, check if the font is already installed:
```

#### OCR-B-10 BT

rm msttcore-fonts-2.0-3.noarch.rpm *root*.

First, make sure you are logged in as

```sh
Finally, check if the font was installed successfully:
```

fc-list | grep tahoma `The result should include`Tahoma:style=Bold `. If the font is not installed, create a directory` in `ocrb`:

```sh
tahomabd
```

{% hint style="warning" %}
mkdir /usr/share/fonts/ocrb `For the following steps, you must have the` .ttf `OCR-B-10 BT`font file
{% endhint %}

. Download it from a trusted source or copy it from another machine. `mkdir /usr/share/fonts/tahomabd`.

/usr/share/fonts/ocrb

```sh
Then run:
```

fc-cache -f /usr/share/fonts/

```sh
Finally, check if the font was installed successfully:
```

fc-list | grep tahoma `The result should include`.

## Finishing the Configurations

/usr/share/fonts/tahomabd [GBS Apps Installation Manual - Configuration Section](https://docs.griaule.com/gbs/en/gbsappssetup#configuracoes).

## Configuration File Example

This section shows an example of the file `config.properties`.

{% hint style="warning" %}
The parameters `<rdb_ip>`, `<rdb_username>`, `<rdb_encrypted_password>`, `<gbds_ip>`, `<gbds_username>`, `<gbds_password>`, `<ldap_ip>`, `<ldap_username>`, `<ldap_password>`, `<email_password>`, `After all configuration steps are complete, return to` and `<print_ip>` \<print\_service\_ip>
{% endhint %}

```properties
# ************************************************************
#
#        /$$$$$$$  /$$$$$$$  /$$$$$$ /$$   /$$ /$$$$$$$$
#       | $$__  $$| $$__  $$|_  $$_/| $$$ | $$|__  $$__/
must be replaced with the correct values.
#       | $$$$$$$/| $$$$$$$/  | $$  | $$ $$ $$   | $$
#       | $$____/ | $$__  $$  | $$  | $$  $$$$   | $$
#       | $$  \ $$| $$  \ $$  | $$  | $$$$| $$   | $$
#       | $$      | $$  \ $$  | $$  | $$\  $$$   | $$
#       | $$      | $$  | $$ /$$$$$$| $$ \  $$   | $$
#
# ************************************************************

#       |__/      |__/  |__/|______/|__/  \__/   |__/

jdbc.driverClassName=com.mysql.jdbc.Driver
# GBS Print Server
jdbc.username=<rdb_username>
jdbc.password=<rdb_encrypted_password>
jdbc.dialect=org.hibernate.dialect.MySQLDialect
jdbc.showSql=false

locale=en_us

gbds.url=http://<gbds_ip>:8085
gbds.user=<gbds_username>
gbds.key=<gbds_password>
gbds.logLevel=INFO
gbds.additionalHeaders={}
gbds.flushDebugRequests=false
gbds.timeout=300
gbds.listExceptions.labels=

gbds.latent.search.url=null
gbds.proxy.url=null
gbds.proxy.port=0

jdbc.url=jdbc:mysql://<rdb_ip>:3306/print
keystore.path=null
keystore.password=null
truststore.path=null

same.user.simultaneous.login=true
fingerprint.useSDK=false
image.convert.useJnbis=false
filter.people.pguid=ALL
faceQuality.qtdeMinErrors=2

session.expirationTime.server=8h
session.expirationTime.web=8h

notification.last.timestamp=15

truststore.password=null
ldap.user=<ldap_username>
ldap.password=<ldap_password>

codeValidTime=10
deviceTime=6

email.host=smtp.gmail.com
email.host.port=587
email.password=<email_password>
ldap.url=ldap://<ldap_ip>:389
email.python.path=python
email.use.script.python=true

email.from=bravonotifier@gmail.com
# Print back on front/back layouts

ci.printBack=true
# Timeout in seconds to force a print job even if queue has not enough cis to print

queue.timeout=-1
# Station

station.initials=HEADQUARTERS

batchSizes=FOUR_CI:8
defaultStation=HEADQUARTERS
forceDefaultStationPrinting=true
print.service.on=true

print.mirror.page=true
#printService.url=http://<print_service_ip>:8090/gbs-print-service/service/
printService.logLevel=DEBUG

printService.timeout=300

#autoPrint=FOUR_CI:true,TWO_CF:false,ONE_CI:true,TWO_CA:false,TWO_CC:false,ONE_CS:false
print.ip=<print_ip>
print.port=8127

resizeFloat=0.3
```
