PHPOffice/PHPWord · error · PhpOffice\PhpWord\Exception\Exception

Unable to load PDF Rendering library

Error message

Unable to load PDF Rendering library

What it means

Constructor guard: the PDF renderer's include file (e.g. dompdf/tcpdf library entry) was not found under Settings::getPdfRendererPath(), so no PDF rendering library is available and the writer cannot be instantiated. Fires when the PDF library is not installed or pdfRendererPath is misconfigured.

Solutions

  1. Install the PDF rendering library (dompdf, tcpdf, or mPDF) via Composer and make its main file present under the configured library path.
  2. Set Settings::setPdfRendererPath() to the directory containing the library's include file.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/PhpWord/Writer/PDF/AbstractRenderer.php:94 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of PHPOffice/PHPWord@aef95c0415 (2026-09-14). Data as JSON: /api/errors/74903dc2f191865b. Report an issue: GitHub.

Appendix: source

Thrown at src/PhpWord/Writer/PDF/AbstractRenderer.php:94

    /**
     * Create new instance.
     *
     * @param PhpWord $phpWord PhpWord object
     */
    public function __construct(PhpWord $phpWord)
    {
        parent::__construct($phpWord);
        $this->isPdf = true;
        if ($this->includeFile != null) {
            $includeFile = Settings::getPdfRendererPath() . '/' . $this->includeFile;
            if (file_exists($includeFile)) {
                /** @noinspection PhpIncludeInspection Dynamic includes */
                require_once $includeFile;
            } else {
                // @codeCoverageIgnoreStart
                // Can't find any test case. Uncomment when found.
                throw new Exception('Unable to load PDF Rendering library');
                // @codeCoverageIgnoreEnd
            }
        }

        // Configuration
        $options = Settings::getPdfRendererOptions();
        if (!empty($options['font'])) {
            $this->setFont($options['font']);
        }
    }

    /**
     * Get Font.
     *
     * @return string
     */
    public function getFont()
    {

View on GitHub (pinned to aef95c0415)