FairCareAI uses Playwright for PDF generation. Setup is identical on macOS, Windows, and Linux!
pip install playwrightpython -m playwright install chromiumThat's it! ✅ Works everywhere without system dependencies!
Generate PDFs from your audit results:
from faircareai import FairCareAudit
# Run audit
audit = FairCareAudit(data=df, pred_col="prob", target_col="outcome")
audit.add_sensitive_attribute(name="race", column="race", reference="White")
results = audit.run()
# Generate PDF reports
results.to_governance_pdf("governance_report.pdf") # Streamlined 3-5 page report
results.to_pdf("technical_report.pdf") # Comprehensive technical report
results.to_html("interactive_report.html") # Interactive web report- File Size: ~460 KB (with interactive charts)
- Charts: 12 high-quality visualizations (4 overall + 8 subgroup)
- Content: Executive summary, key metrics, plain language findings
- Audience: Healthcare leadership, governance committees
- File Size: ~210 KB
- Charts: Full suite of performance and fairness visualizations
- Content: Detailed statistical analysis, confidence intervals, metrics
- Audience: Data scientists, statisticians, technical teams
- File Size: ~56 KB
- Charts: 12 interactive Plotly charts with zoom/pan/hover
- Features: No PDF conversion - pure web interface
- Use Case: Interactive exploration, presentations, web dashboards
pip install playwright
python -m playwright install chromiumWorks on both Apple Silicon and Intel Macs!
pip install playwright
python -m playwright install chromiumNo GTK3 runtime needed!
pip install playwright
python -m playwright install chromiumNo system packages required!
FROM python:3.12-slim
# Install Playwright
RUN pip install playwright
# Install Chromium browser
RUN python -m playwright install-deps chromium
RUN python -m playwright install chromium
# Install your package
RUN pip install faircareai[export]
WORKDIR /appSolution: Install the Chromium browser
python -m playwright install chromiumSolution: Install Playwright package
pip install playwrightCause: Network timeout loading Plotly.js
Solution: Increase timeout (usually only needed on slow connections)
# Not implemented yet - contact support if needed❌ macOS: Requires Homebrew + 4 system libraries + environment variables ❌ Windows: Requires GTK3 runtime installer + PATH configuration ❌ Linux: Requires system packages via apt/dnf/pacman ❌ Charts: Must convert Plotly to static SVG (complexity + quality loss) ❌ Setup Time: 10-30 minutes per platform ❌ Support: Platform-specific debugging nightmares
✅ All Platforms: Same 2 commands everywhere! ✅ Charts: Native JavaScript rendering = perfect quality ✅ Setup Time: 2 minutes (mostly download time) ✅ Support: Works identically on all systems ✅ Size: ~200MB one-time browser download (vs managing system libs)
| Operation | Time | Notes |
|---|---|---|
| Chromium Download | 1-2 min | One-time setup |
| PDF Generation | 3-5 sec | Per report |
| HTML Generation | <1 sec | Instant |
Playwright supports many PDF customization options:
# Not yet exposed in public API
# File an issue if you need custom margins, page size, etc.Playwright runs in headless mode by default (no visible browser window). This is perfect for:
- Server environments
- CI/CD pipelines
- Batch processing
- Docker containers
pip install faircareaipip install "faircareai[export]" # Includes Playwright
python -m playwright install chromiumpip install "faircareai[export]"
python -m playwright install chromium| Feature | WeasyPrint | Playwright |
|---|---|---|
| Setup (macOS) | Homebrew + 4 libs + env vars | pip install + browser |
| Setup (Windows) | GTK3 installer + PATH | pip install + browser |
| Setup (Linux) | System packages | pip install + browser |
| JavaScript Support | ❌ No | ✅ Yes |
| Interactive Charts | ❌ Must convert to SVG | ✅ Native rendering |
| Cross-Platform | ✅ Identical everywhere | |
| Maintenance | ✅ Self-contained | |
| CI/CD Friendly | ✅ Simple setup | |
| Docker Size | ~500MB (with system libs) | ~200MB (Chromium only) |
Winner: Playwright 🏆
If you were using an older version of FairCareAI with WeasyPrint:
pip uninstall weasyprintpip install playwright
python -m playwright install chromium# Your existing code works identically!
results.to_governance_pdf("report.pdf")
results.to_pdf("technical.pdf")The API is 100% backward compatible. Only the underlying engine changed.
Q: Do I need to install Chromium every time I deploy?
A: Yes, but it's automated: python -m playwright install chromium
Q: Can I use Firefox or WebKit instead? A: Chromium is recommended for best PDF rendering. Contact support if you need alternatives.
Q: Does this work in restricted environments without internet? A: Yes! Install Chromium once with internet, then works offline.
Q: What's the browser cache size?
A: ~200MB for Chromium. Located in ~/.cache/ms-playwright/
Q: Can I uninstall after generating PDFs? A: No - Chromium is needed each time you generate a PDF.
Q: Does this open browser windows on my screen? A: No - runs headless (background) by default.
If you encounter issues:
- Check Playwright is installed:
pip show playwright - Check Chromium is installed:
python -m playwright install chromium - Try test script:
python test_pdf_output.py - File an issue: https://github.com/your-repo/faircareai/issues
Last Updated: 2026-01-08 Tested On: macOS 15.3, Windows 11, Ubuntu 22.04 Python: 3.10+ Status: ✅ Production Ready