Files
NetBox-Customer-Export/netbox_customer_export/renderers/html.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

20 lines
522 B
Python

import base64
import mimetypes
from django.template.loader import render_to_string
def _logo_data_uri(path):
if not path:
return None
mime = mimetypes.guess_type(path)[0] or "image/png"
with open(path, "rb") as f:
return f"data:{mime};base64,{base64.b64encode(f.read()).decode('ascii')}"
def render_html(doc):
return render_to_string(
"netbox_customer_export/document.html",
{"doc": doc, "b": doc.branding, "logo": _logo_data_uri(doc.branding.get("logo_path"))},
)