/pdf-Engine

PDF API. JSON to PDF. PDF Template Management, Visual HTML Template Editor and API to render PDFS by json data

Primary LanguagePHPMIT LicenseMIT

Alt text Alt text

PDF Template Management, Visual HTML Template Editor and API to render PDFS by json data

PDF ENGINE

VERSION: development: This is a prerelease version, feel free to play with it and to submit feature requests

Planned features until the first release:

  • User Management and JWT login for API
  • Documentation
  • Installation guide
  • Dolibarr Connector

IMPORTANT!

The system has 2 dependencies:
wkhtmltopdf must be installed and the php function proc_open must be active!

Short installation guide, for those who can't wait.

  • 1. Copy all the files to your web server.
  • 2. create a mysql database.
  • Now navigate to the pdfengine folder (where app, public, etc. are located) where you will find an .env file (or rename .env.example to .env). In this file you have to adjust the following fields:

    DB_CONNECTION=mysql
    DB_HOST=127.0.0.1 <--- your database host (or localhost)
    DB_PORT=3306
    DB_DATABASE=pdfengine <--- database name
    DB_USERNAME=root <--- database user
    DB_PASSWORD= <--- database password

    Further, the following should be adjusted in the .env:
    APP_KEY= <--- Enter a base64 encryption key here.
    APP_URL=http://localhost <--- Enter the apphost here.

  • Save the .env file and execute the following command in the terminal:
    php artisan migrate
  • This command creates the necessary database tables.
    The system is based on Laravel, therefore the public folder must be selected as the "running directory" and rewrite rules must be used according to the Laravel documentation.

    Now the PDF engine can already be used http://localhost/templates

    Use of the API

    After the PDF engine has been installed and the first template has been created, the template can be accessed via the API link. To do this, data and filename must be sent via POST as json.
    Example: The template is called invoice
    POST http://localhost/api/render/template/invoice
    {
    "data":{"docname": "invoice"},
    "filename":"invoice123"
    }

    Include data in the PDF.

    The PDF engine uses https://handlebarsjs.com/ to render the JSON data into the PDF.
    If, for example, {{docname}} is included in a template, the text that was transferred in the JSON with the key "docname" will appear later in the PDF at this position.