Skip to content

Getting Started Guide

This guide will walk you through the steps to start ComPDFKit Processor. It will also show you how to use it to process documents.

Requirement

ComPDFKit Processor for Linux can run on multiple platforms. It supports the following operating systems:

  • Ubuntu, Fedora, Debian, or CentOS. It also supports Ubuntu and Debian derivatives such as Kubuntu or Xubuntu. Currently, it only supports 64-bit Intel (x86_64) processors.

Regardless of the operating system you are using, you will need at least 4GB of RAM.

Install Docker

ComPDFKit Processor for Linux is distributed in the form of a Docker container. To run it on your computer, you need to install the Docker runtime environment for your operating system.

Please follow the instructions on the Docker official website to install and start Docker Engine.

After installing Docker, you can use the installation instructions to install Docker Compose. The instructions can be found at here.

Start ComPDFKit Processor

ComPDFKit Processor also provides a simple web page that is primarily used to render PDF files and display them on a web page. You can directly process PDF files on the web page. You can access it through localhost:7000/index.html.

ComPDFKit Processor for Linux uses MySQL database for data storage. Therefore, you need to configure an available MySQL database and import the "compdfkit.sql" file into your database.

Register Docker Hub, and reference the mirrors of ComPDFKit Processor for Linux using the compdfkit/compdfkit:tag. To pull the latest mirrors of ComPDFKit Processor for Linux, run the following command:

docker pull compdfkit/compdfkit:1.2.0

You need to ensure that docker-compose is already installed on your system. To install docker-compose, please visit Overview of installing Docker Compose | Docker Docs to learn how to install it on your operating system.

First, you need to create a docker-compose.yml file at a location of your choice. You can use vim docker-compose.yml to edit it. Copy the following content into the docker-compose.yml file:

yaml
version: '3.3'
services:
  compdfkit_processor:
    restart: always
    image: compdfkit/compdfkit:1.2.0
    container_name: compdfkit_processor
    ports:
      - 7000:7000
    environment:
      LICENSE_KEY: your LICENSE_KEY
      DB_URL: dbmysql:3306/compdfkit
      DB_USERNAME: root
      DB_PASSWORD: mypassword
      # Temporary storage space for file processing.
      TMP_PATH: /tmp/compdfkit
      # Error message language setting, supports Chinese and English (default is en).
      LANGUAGE: en
    depends_on:
      - dbmysql
  dbmysql:
    image: mysql:8.0.27
    restart: always
    command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --skip-character-set-client-handshake --skip-name-resolve --max_allowed_packet=500M --max_connections=1000 --default-authentication-plugin=mysql_native_password
    container_name: dbmysql
    ports:
      - 3306:3306
    environment:
      MYSQL_ROOT_PASSWORD: mypassword
      MYSQL_DATABASE: compdfkit
    volumes:
      - ./data:/var/lib/mysql
      - ./compdfkit.sql:/docker-entrypoint-initdb.d/compdfkit.sql

Next, you need to copy the "compdfkit.sql" file to the same directory level as the docker-compose.yml file.

Then you need to execute the following command:

sh
docker-compose up

When you see the following content, it means the project has started successfully:

shell
Running ComPDFKit Processor version 1.2.0 port(s) 7000 (http)

API Configuration

Required:

  • LICENSE_KEY - This is the license key used to activate ComPDFKit Processor. If not specified or incorrect, ComPDFKit Processor will not be able to start.

  • DB_URL - This is the database connection address, composed of <host>:<port>/<database name>. If not specified or incorrect, ComPDFKit Processor will not be able to start.

  • DB_USERNAME - This is the username of database connection. If not specified or incorrect, ComPDFKit Processor will not be able to start.

  • DB_PASSWORD - This is the user password of database connection. If not specified or incorrect, ComPDFKit Processor will not be able to start.

Optional:

  • SERVER_PORT - ComPDFKit Processor listening port. Default is 7000.

  • TMP_PATH - Temporary storage space for loading temporary files. Default is /tmp/compdfkit.

  • LANGUAGE - Interface error description language zh_cn || en. Default is en.

  • CONVERT_TIMEOUT - File processing timeout in minutes. Default is 15.

Install curl

The interaction with the processor is done through its HTTP API: sending requests with files and commands, and receiving result files. Before that, you need to have curl installed in order to make API calls. Most desktop Linux distributions come bundled with curl. You can check if it is already installed by running the command curl --version in the terminal. If you get an error, you can install it using the package manager of your distribution: curl.

Ubuntu/Debian :

shell
apt-get update && apt-get install -y curl

Example Feature: PDF Conversion

Everything is now all set up, and you can begin using the ComPDFKit Processor for PDF document processing, using the PDF to Word conversion function as an example. For more API calls for other functions, please refer to the “ComPDFKit_Processor_API_Reference_v1.2.0.pdf” .

  • Select the file you wish to perform the operation on and move it to your desired location (e.g., document.pdf file).

  • Run the following command:

shell
curl -f -X POST http://localhost:7000/file/handle \
-H "Content-Type: multipart/form-data" \
-F file=@"document.pdf" \
-F executeType="pdf/docx" \
-F password="file open password" \
> result.docx

Open the file result.docx in Word Viewer - you will see a Word document.