Print service plugin
Plugin-Download (requires login)
The plugin Print Services is available separately and lets you create a PDF document from a form that is optimized for printing. This plugin is subject to additional charge.
Technical details
To use the Print-Service plugin, it is necessary to install Node.js and the Print Server. This can be installed on the same server as the Xima® Formcycle master server.
Installation
The installation of the required Print Server requires different procedures depending on the operating system.
Installation Print Server on Windows
Installation of Node.js
- 1. Download the LTS version from https://nodejs.org/
- 2. Run the MSI file
- 3. Run the wizard steps, leaving default settings as they are
Installation steps for the Print Server
- 4. Download the Print Server installation files from the Customer Cloud here.
- 5. unzip the ZIP file "print_server_fc.zip" and move the content to the folder print_server_fc under C:\Programs\.
To install, open the command line (cmd) with administrative privileges and execute the following commands:
npm install
npm install -g node-windows
npm link node-windows
node install-windows-service.js
There now exists a new service FORMCYCLE Print Server. Please check if this is also started before you run a test. The script install-windows-service.js contains default variables for installing the print service.
- The service is installed on port 8090 by default. To change this, you need to adjust the --port=8090 parameter in the install-windows-service.js file.
- Logging is enabled by default. To change this set the parameter --verbose=true to --verbose=false.
After the installation, a folder named deamon is created for the log files.
Uninstall
Für die Deinstallation des Print Servers, öffnen Sie eine Kommandozeile (cmd) mit administrativen Berechtigungen und führen Sie folgende Befehle aus.
node uninstall-windows-service.js
Installing Print Server under Linux
Installation steps for installing Node.js and the Print Server
To install, open the console and run the following commands:
# Debian 10 - If you are logged in as root:
wget "https://customer.formcycle.eu/index.php/s/0GBtp1HtQHJMzQx/download?path=/&files=install_printserver_debian10.sh" -O install_print_server.sh
# Debian 10 - or if you are logged in as a normal user with sudo rights:
wget "https://customer.formcycle.eu/index.php/s/0GBtp1HtQHJMzQx/download?path=/&files=install_printserver_debian10_sudo.sh" -O install_print_server.sh
# Ubuntu 16 - If you are logged in as root:
wget "https://customer.formcycle.eu/index.php/s/0GBtp1HtQHJMzQx/download?path=/&files=install_printserver_ubuntu16.sh" -O install_print_server.sh
# Make file executable
chmod 750 install_print_server.sh
# Start installation
./install_print_server.sh
# Run Print Server
systemctl start printserver
In the first lines of the script - via the variables PRINTSERVER_USER and PRINTSERVER_USER_PWD - the user name/password to be created can be adjusted.
The verbose parameter can be used to enable/disable the log output. The scripts for the service should be located at /home/formcycle/print_server. In the start script the verbose parameter can be adjusted.
Translated with www.DeepL.com/Translator (free version)
Uninstall
To uninstall the Print Server, open a command line (cmd) with administrative privileges and execute the following commands:
Test
To check if the installation was successful, the service can be called on the server for a test:
http://localhost:8090/pdf?orientation=landscape&format=A4&wait=false&marginTop=0mm&formURL=http://www.formcycle.de
Plugin setup
Print-Service Plugin Installation
In order for the plugin to be available in Xima® Formcycle as an action in the workflow, it must be deployed in the System Plugin section of the management interface. Instructions for installing plugins can be found here.
If the old version of the print service plugin (phantom plugin) was already installed, the following procedure is recommended for installation:
- Disable the phantom plugin
- Delete the phantom plugin
- Upload new print service plugin
- Proceed with the configuration
Plugin Configuration
After the plugin has been installed, the service URL must be adjusted. This is defined in the plugin via the mandatory parameter pdf.print.services.url.
If the installation was done on the same server as Xima® Formcycle, then specify localhost as the domain. If no changes have been made to the port, the setting 8090 is retained.
For example: http://localhost:8089/pdf
This completes the setup of the print service plugin and it is available as an action in the workflow processing.
Troubleshooting
Command npm not found
Under Windows it is possible that after the NodeJS installation the environment variables are not set correctly and so npm install cannot be executed. This was also the case if the default path under C:/Programs was not used during the NodeJS installation. So check in the path if these are existing. The following must be done for this:
- Call up the environment variables via Control Panel > System > Advanced System Settings > Environment Variables button.
- In Path you should find the following entries:
- Confirm everything with Ok. The console then be opened again with admin rights.
Command npm install leads to timeout
If the npm install command does not work due to a proxy, then the general proxy setting is not sufficient. Therefore, the following must be executed via console:
npm config set https-proxy https://proxy.domain:port
If user data is required:
npm config set https-proxy https://user:pass@proxy.domain:port
More information can also be found here: http://www.fladi.de/2014/02/06/howto-npm-hinter-einem-proxy-verwenden/
Printing does not work
If printing via Xima® Formcycle is not possible, the cause could be that the print service is not reachable. This can be solved by the loopback URL. Under System > General > Loopback URL, loopback base URL: http://localhost:<port>/formcycle
PDF is printed, but the message 404 appears
In this case the print service works correctly because a PDF is already created. It must be checked whether the loopback URL is entered correctly so that the URL to the print service is resolved correctly.
Downloading Chromium fails
The following error message appears on the console after running "npm install":
Error: unable to verify the first certificate
The described steps are only a workaround and the environment variables should be set back to the default values after the successful installation!
PS C:\test> npm set strict-ssl false
Usage and options
To use this plugin, go to the workflow processing configuration, click on new action and select this plugin. The following options are used to configure the plugin action:
- File name
- File name of the created PDF document.
- Print mode
- Input elements as text: Input elements are converted into plain text fields and the form is adapted to the width of the page.
- Print mode
- Web view: No changes are made to the form and it is converted so that it looks as closely as it does in a web browser as possible.
- Zoom factor
- Factory by which the form is scaled. Use this to magnify or scale down very large or very small forms.
- User groups
- A virtual user is created when opening the form with Selenium. Select the user groups here to which this virtual user should belong to. Form elements can be configured to be displayed or editable only for certain user groups.
- URL parameter
- Additional URL parameters added to the URL used when opening the form with Selenium. You can use URL parameters to prefill form fields or access them from within JavaScript.
CSS-Anpassungen für Druckbild
Input elements
To optimize the form for printing, form elements of type input field, text area und select (Drop-Down) may be converted to plain text fields, if the print mode is set to Input elements as text.
Additionally, the CSS classes print and XSpan are added to the converted input element that can be used for styling them. For example, in order to change the font size, you can use the following CSS:
font-size: 18pt;
font-family: serif;
}
To overwrite some properties of the default CSS shipped with Xima® Formcycle, use more specific selectors such as:
font-size: 18pt;
font-family: serif;
}
Most properties do not require this, however.
Enforce page break
To create a defined page break, the page-break attributes must be set via CSS. The corresponding container or element has to be selected via the xn attribute. Please note that the CSS property display must be set to block, otherwise no line break will be created. In this example, a line break should be created before the container div1.
display: block !important;
page-break-before: always;
}
Avoid page break
The default setting for printing is that a page break is inserted after each page of the form:
.CXPage:not(:first-child ), .page-break {
display: block !important;
page-break-before: always;
}
}
In order to avoid breaks, the following rule needs to be defined in the CSS tab of the form:
.CXPage:not(:first-child ) {
page-break-before: avoid;
}
}
Usage of other fonts
Technical requirements
In order for fonts to be used and embedded in the created PDF documents, it is generally necessary for them to be installed on the server running the Print-Server.
Inclusion via CSS
To include a font installed on the server for printing, it must be explicitly defined with a @media print query and set for use by the appropriate form elements. In the simplest case, this can look like the following example:
@font-face {
font-family: 'DejaVu Sans';
src: local('DejaVu Sans');
}
.xm-form.modern *, .modern .XPage * {
font-family: "DejaVu Sans";
}
}
Here it is especially important that the identifier entered at local() corresponds to the name of the font.
Legal notice
Fonts sometimes have very tightly defined license terms and are priced differently depending on their intended use. It should be noted that fonts for creating PDFs must be embedded in them, which for many commercial fonts requires a different license than for delivery via a web server for the purpose of displaying a web page in a web browser.
In fonts of type TrueType and OpenType information about the embeddability of the font can be stored directly. Depending on what is configured there, a font may not be embeddable and will instead be rendered by the Print-Service-Plugin only as a vector graphic in the created PDF documents.