Skip to main content

PDF export

Instruction for Fixing PDF Export Issues in BookStack on Ubuntu 24.04 Using WeasyPrint

1. Install Required Dependencies

Open the terminal and run:

sudo apt-get update
sudo apt-get install python3-pip python3-cffi libcairo2 libpango-1.0-0 \
libpangocairo-1.0-0 libgdk-pixbuf2.0-0 libffi-dev shared-mime-info

These libraries are necessary for WeasyPrint to work correctly and to support font rendering.

2. Install WeasyPrint

Option 1: Using pip

sudo pip3 install weasyprint

If you get the “externally-managed-environment” error, it is recommended to use the system package or a Python virtual environment.

Option 2: Using system package

sudo apt install weasyprint

This will install the utility, usually available at /usr/bin/weasyprint.

3. Verify WeasyPrint Installation

Check the version and environment info:

weasyprint --info

You should see details about the version, supported libraries, Python version, and system info.

4. Configure BookStack to Use WeasyPrint

Open the .env configuration file for your BookStack installation:

sudo nano /var/www/bookstack/.env

Add or modify the following line:

EXPORT_PDF_COMMAND="/usr/bin/weasyprint {input_html_path} {output_pdf_path}"

Make sure the path to weasyprint matches the output of the command which weasyprint.

5. Restart BookStack

 

/opt/bookstack# php artisan config:clear

/opt/bookstack# php artisan cache:clear