Files
NetBox-Customer-Export/netbox_customer_export/renderers/__init__.py
T
MrBlakeandClaude Opus 5.5 8f45bffa99 NetBox Customer Export plugin with configurable branding
Plugin for NetBox 4.6.8–4.6.99 that exports customer documentation
(PDF, Word, HTML preview) for a site, location, tenant or tenant group.
Technicians pick sections, device roles and columns before exporting.

Branding profiles (colors, font, logo, footer, Word template incl. .dotx,
table style, extra CSS) are configurable via PLUGINS_CONFIG and selectable
per export.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 12:43:19 +02:00

24 lines
806 B
Python

class MissingDependency(Exception):
pass
def render(doc, fmt, request=None):
"""Gibt (bytes, content_type, dateiendung) zurück."""
if fmt == "docx":
from .docx import render_docx
return render_docx(doc), "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "docx"
from .html import render_html
html = render_html(doc)
if fmt == "html":
return html, "text/html; charset=utf-8", "html"
try:
from weasyprint import HTML
except (ImportError, OSError) as e:
raise MissingDependency(f"PDF-Export benötigt WeasyPrint (pip install weasyprint + Pango): {e}")
base_url = request.build_absolute_uri("/") if request else None
return HTML(string=html, base_url=base_url).write_pdf(), "application/pdf", "pdf"