Configure pdfRest API Toolkit Container
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:
1 for true or 2 for false. Defaults to 1 for true.REMOVE_ORIGINAL_PROCESSED to be 1. Defaults to 1800000 (30 minutes).1800 (30 minutes)1000.id UUIDs to visually and programatically identify them. Defaults to 1.id UUIDs to visually and programatically identify them. Defaults to 2.https://pdfrest.com.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_CONCURRENCY = 3Setting 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-textendpoint- Once installed,
msCoreFontsare available for use with the Watermark PDF and Add to PDF API Tools, expanding the set of fonts that can be applied.
- Once installed,
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_TAGif you intend to pin your image to a specificpdfrest/pdf-api-toolkitversion. - Update the
--tagoption 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