From e7a73d05700f82588bb66d087284a3cfc1f38ae3 Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Wed, 11 Feb 2026 23:24:51 +0530 Subject: [PATCH] feat: add report export capabilities with Pandoc and WeasyPrint support - Updated Dockerfiles to include Pandoc and WeasyPrint runtime libraries for report generation. - Enhanced report retrieval functionality to include version siblings in the response. - Modified report export process to utilize WeasyPrint for PDF generation, improving output quality. --- Dockerfile.allinone | 7 +++++++ surfsense_backend/Dockerfile | 4 ++++ surfsense_backend/app/routes/reports_routes.py | 2 +- surfsense_backend/pyproject.toml | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Dockerfile.allinone b/Dockerfile.allinone index 7f9f18806..46d670961 100644 --- a/Dockerfile.allinone +++ b/Dockerfile.allinone @@ -121,6 +121,13 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libgbm1 \ libcairo2 \ libpango-1.0-0 \ + # ============================ + # Report export (Pandoc + WeasyPrint runtime libs) + # ============================ + pandoc \ + libpangoft2-1.0-0 \ + libharfbuzz0b \ + libharfbuzz-subset0 \ && rm -rf /var/lib/apt/lists/* # Install Node.js 20.x (for running frontend) diff --git a/surfsense_backend/Dockerfile b/surfsense_backend/Dockerfile index 446479ece..e33a962f8 100644 --- a/surfsense_backend/Dockerfile +++ b/surfsense_backend/Dockerfile @@ -20,6 +20,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libxrender1 \ dos2unix \ git \ + pandoc \ + libpango-1.0-0 \ + libpangoft2-1.0-0 \ + libharfbuzz-subset0 \ && rm -rf /var/lib/apt/lists/* # Update certificates and install SSL tools diff --git a/surfsense_backend/app/routes/reports_routes.py b/surfsense_backend/app/routes/reports_routes.py index b4ee0e889..25764d88d 100644 --- a/surfsense_backend/app/routes/reports_routes.py +++ b/surfsense_backend/app/routes/reports_routes.py @@ -180,7 +180,7 @@ async def export_report( # thread executor to avoid blocking the async event loop. extra_args = ["--standalone"] if format == ExportFormat.PDF: - extra_args.append("--pdf-engine=wkhtmltopdf") + extra_args.append("--pdf-engine=weasyprint") loop = asyncio.get_running_loop() output = await loop.run_in_executor( diff --git a/surfsense_backend/pyproject.toml b/surfsense_backend/pyproject.toml index 2abc07b5e..38da661b3 100644 --- a/surfsense_backend/pyproject.toml +++ b/surfsense_backend/pyproject.toml @@ -64,6 +64,7 @@ dependencies = [ "langchain-unstructured>=1.0.1", "slowapi>=0.1.9", "pypandoc>=1.16.2", + "weasyprint>=68.1", ] [dependency-groups]