Configure pdfRest API Toolkit Container

Learn how to configure the pdfRest API Toolkit Containerto meet your needs.

Environment variables

The pdfRest API Toolkit Container is highly configurable using environment variables. These control a variety of features, such as maximum file upload size or CPU concurrency. The list of environment variables and their functions are below:

LICENSE_KEYstring
Required field for license-managed versions of the API Toolkit Container only. Cloud API service API Keys are not License Keys. This setting also does not apply to the Toolkit on AWS.
REMOVE_ORIGINAL_PROCESSEDinteger
Controls whether uploaded and processed documents are deleted from the system. Set to 1 for true or 2 for false. Defaults to 1 for true.
REMOVE_ORIGINAL_PROCESSED_DELAYinteger
Controls how long before those documents are deleted from the system in milliseconds. Requires REMOVE_ORIGINAL_PROCESSED to be 1. Defaults to 1800000 (30 minutes).
MAX_PROCESS_TIMEintiger
Controls how long a single document will process before timing out in seconds. Defaults to 1800 (30 minutes)
MAX_UPLOAD_SIZEintiger
Controls the maxiumum uploaded file size in MB. Defaults to 1000.
INPUT_KEYstring
A value appended to all input file id UUIDs to visually and programatically identify them. Defaults to 1.
OUTPUT_KEYstring
A value appended to all output file id UUIDs to visually and programatically identify them. Defaults to 2.
REDIRECT_ROOT_URLstring
Controls the url that users will be redirected to if they try to manually navigate to the server domain. Defaults to https://pdfrest.com.
PDFREST_SERVER_DOMAINboolean
Controls which domain the pdfRest API will return in a outputURL for the end-user to retrieve their files after processing. Note: Requires a domain record to be configured. Unless you intend to load a TLS certificate for the Container, set this to an http:// value.
PDFREST_MAX_CLU_CONCURRENCYinteger
Sets the maximum number of concurrent processing requests that can run; any additional requests will enter the local queue. This prevents performance issues during batches of simultaneous requests. The default is the number of CPU cores minus 1, with a minimum of 1. As an example, an instance with 4 CPU cores would default to PDFREST_MAX_CLU_CONCURRENCY = 3

Setting variables in Docker

In docker these variables can be set under:

services > **pdfrest_service** > env

services:
  pdfrest:
    platform: linux/amd64
    image: pdfrest/pdf-api-toolkit:latest
    restart: always
    environment:
      - LICENSE_KEY=YOUR-LICENSE-KEY-VALUE-HERE
      - PDFREST_SERVER_DOMAIN=https://pdfrest.YOUR-COMPANY-HERE.com
      - MAX_UPLOAD_SIZE=1000

Setting variables in Kubernetes

In Kubernetes they can be set under:

spec > template > spec > containers > **pdfrest_container** > env

spec:
  template:
    spec:
      containers:
        - name: pdfrest
          image: pdfrest/pdf-api-toolkit:latest
          env:
            - name: LICENSE_KEY
              value: YOUR-LICENSE-KEY-VALUE-HERE
            - name: PDFREST_SERVER_DOMAIN
              value: https://pdfrest.YOUR-COMPANY-HERE.com
            - name: REMOVE_ORIGINAL_PROCESSED
              value: false

msCoreFonts

Microsoft Core Fonts are not licensed to be distributed with pdfRest API products but they are freely available from SourceForge for you to install. These are optional when deploying the pdfRest API and enable the following features:

  • Support maximum file size reduction with Compress PDF by enabling font subsetting
    • Subsetting the fonts that are embedded in the document is an important step to reduce PDF file size. The subset of the font contains only those font characters actually used in the PDF document.
  • Support font embedding, a required step to Convert to PDF/A
    • Embedding fonts in your output PDF document ensures that the document can be opened and viewed on any machine, because the fonts travel with that document. Quite literally, the necessary font files are saved within that PDF file. This is required for all PDF/A specifications to support long-term preservation.
  • Expand the set of supported fonts that may be used with Watermark PDF and Add to PDF's /pdf-with-added-text endpoint
    • Once installed, msCoreFonts are available for use with the Watermark PDF and Add to PDF API Tools, expanding the set of fonts that can be applied.

If you receive either of the follow error messages in the container logs, then msCoreFonts is not included with your deployment.

Microsoft Core Fonts not found
Setting font subsetting to false

Adding msCoreFonts to the Image

Use the following Dockerfile to add the Microsoft Core Fonts package to a pdfRest image.

# syntax = docker/dockerfile:1.2
ARG PDFREST_IMAGE=pdfrest/pdf-api-toolkit
ARG PDFREST_TAG=latest
FROM $PDFREST_IMAGE:$PDFREST_TAG

# Install the Microsoft Core Fonts
# See: https://mscorefonts2.sourceforge.net/
RUN dnf install -y epel-release \
    && dnf install -y curl cabextract xorg-x11-font-utils fontconfig \
    && rpm -i https://downloads.sourceforge.net/project/mscorefonts2/rpms/msttcore-fonts-installer-2.6-1.noarch.rpm \
    && dnf clean all \
    # Update the profiles based on the presence of the Microsoft Core Fonts \
    && node /opt/datalogics/pdf-utility/config/update_profiles.js

Use a command like what follows, together with the supplied Dockerfile, to create an pdfrest image with the fonts installed:

env DOCKER_BUILDKIT=1 docker build . \
  --build-arg PDFREST_IMAGE=pdfrest/pdf-api-toolkit \
  --build-arg PDFREST_TAG=latest \
  --tag my-repo/my-image

Customize this command to fit your needs:

  • You can update PDFREST_TAG if you intend to pin your image to a specific pdfrest/pdf-api-toolkit version.
  • Update the --tag option to point the output to your internal or personal registry.

Once the fonts are added, the pdfRest API Toolkit Container will automatically configure itself to work with them, enabling the features described above. You will see the following messages in the Container logs that indicate that the fonts were found, subsetting has been turned on, and the profiles have been updated:

Microsoft Core Fonts found
Setting font subsetting to true
Optimization profiles updated