Class Pd4Server


  • public final class Pd4Server
    extends java.lang.Object
    A thin HTTP service around the PD4ML engine: one long-lived process with a warm engine (the font cache is primed once) and a bounded worker pool, so the JVM/font warmup is paid at start, not per request. The deployment shape recommended for containers - run N stateless replicas behind the orchestrator's load balancer; see design/docker-licensing.md and docker/.

    No external dependencies: the JDK's own HttpServer. Each request builds its own PD4ML and its own temp state, so conversions are isolated; concurrency is bounded by the worker pool. Intended to sit behind an auth gateway / ingress - it does no authentication itself.

    It exposes the common, single-document conversion options of Pd4Cmd as query parameters. Options that need a richer request than a URL carries - HTML page headers/footers, encryption passwords, overlays/merging of extra files, per-page image output, XSL - are deliberately not exposed here; use Pd4Cmd or the library for those.

    • POST /convert - request body is the HTML; the response is the converted document. Query parameters: format (pdf|pdfa|pdfua|docx|rtf|markdown, default pdf), pagemarkers (true: Markdown with a <!-- page N --> marker at each page start), page (a PageSize name such as A4, default A4), orientation (portrait|landscape), width (the HTML layout width in px), insets (page margins "top,left,bottom,right,unit" with unit mm or pt), encoding (the input character set), base (a base URL for relative resources), forms (true to emit interactive form fields), bookmarks (headings|anchors), engine (v42 default|v40), bgcolor, nohyperlinks, kerning, ligatures and multicolumn ("columns,gap").
    • GET /healthz - liveness/readiness, 200 "ok".
    • GET / - a one-line usage string.

    Configuration (environment variables): PD4ML_PORT (8080), PD4ML_WORKERS (available processors), PD4ML_LICENSE (path to the license, default pd4ml.lic - mount it as a read-only secret, do not bake it into the image), PD4ML_FONTS (a font-set directory, optional - the Standard-14 faces are bundled), PD4ML_MAX_BYTES (max request body, 20 MiB), PD4ML_WIDTH (default layout width, 800), PD4ML_ALLOWED_LOCATIONS (comma/semicolon list of resource-location prefixes to allow; set it to keep the converter from fetching arbitrary URLs - an SSRF guard).

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void main​(java.lang.String[] args)  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception