Skip to content

Inline SVG Rendering

Aryeh Citron edited this page Apr 14, 2026 · 4 revisions

Inline SVG Rendering

Inline SVG Rendering embeds PlantUML sequence diagrams directly into the HTML report as <svg> elements instead of using <img> tags pointing to rendered image URLs. This is a prerequisite for Internal Flow Tracking (clickable arrows) and can also be used independently for better SVG integration.


Enabling Inline SVG Rendering

Set InlineSvgRendering = true on your ReportConfigurationOptions:

new ReportConfigurationOptions
{
    InlineSvgRendering = true,
    PlantUmlImageFormat = PlantUmlImageFormat.Svg,  // Required for Server/Local
    // ... other options
}

Note: InternalFlowTracking defaults to true, which automatically forces InlineSvgRendering to true for Server/Local rendering — you don't need to set it explicitly.


How It Works

The behaviour depends on your PlantUmlRendering mode:

Server Rendering (PlantUmlRendering.Server)

  1. During report generation, DefaultDiagramsFetcher fetches the SVG from the PlantUML server using HttpClient (instead of generating an <img src="https://github.com/..."> URL).
  2. The XML declaration is stripped from the SVG response.
  3. The raw SVG markup is embedded directly in the HTML report inside a <div class="plantuml-inline-svg" data-diagram-type="plantuml"> container.

Local Rendering (PlantUmlRendering.Local)

  1. During report generation, DefaultDiagramsFetcher renders SVG bytes in-process via IKVM using LocalDiagramRenderer.
  2. The XML declaration is stripped and the SVG markup is embedded inline, same as the server path.

Browser Rendering (PlantUmlRendering.BrowserJs)

Browser rendering already produces inline SVG (the PlantUML JS engine renders <svg> elements directly into the DOM). InlineSvgRendering has no additional effect in this mode.


When to Use

Use case Recommended
You want Internal Flow Tracking Automatic — InternalFlowTracking defaults to true and forces it
You want SVGs responsive to CSS styling Yes — inline SVGs inherit page styles
You want to manipulate diagram SVGs with JavaScript Yes — inline SVGs are part of the DOM
You want pre-rendered <img> tags for simplicity No — use default rendering
You want loading="lazy" on images No — inline SVGs are part of the page content

Configuration

Property Type Default Description
InlineSvgRendering bool false When true, embeds SVG diagrams inline in the HTML instead of using <img> tags. Requires PlantUmlImageFormat.Svg for Server/Local rendering. Automatically enabled when InternalFlowTracking is true.

HTML Output

With inline SVG rendering enabled, the report emits:

<div class="plantuml-inline-svg" data-diagram-type="plantuml">
  <svg xmlns="http://www.w3.org/2000/svg" ...>
    <!-- Full SVG content -->
  </svg>
</div>

Instead of the default:

<img src="https://plantuml.com/plantuml/svg/..." loading="lazy" />

The data-diagram-type attribute is used by DiagramContextMenu to locate diagram containers for right-click context menus and other interactive features.


Context Menu

Right-clicking on any diagram container with a data-diagram-type attribute opens a custom context menu. The menu adapts its items based on the content type of the container.

Supported Content Types

data-diagram-type Content Menu items
plantuml SVG diagram (inline or browser-rendered) Full menu — PNG, PNG (no transparency), SVG, source, open in tab
flamechart HTML flame chart bars PNG only — Copy as PNG, Save as PNG
calltree HTML call tree list PNG only — Copy as PNG, Save as PNG

SVG Menu Items

For SVG-based diagrams (plantuml):

  • Copy as PNG — Renders SVG to a 2× canvas and copies to clipboard (transparent background)
  • Copy as PNG (no transparency) — Renders SVG to a 2× canvas with the diagram's background colour filled first. Background is detected from the first <rect> element's fill attribute.
  • Copy as SVG — Copies the serialised SVG markup to clipboard
  • Copy PlantUML source — Copies the raw diagram source code
  • Save as PNG / Save as PNG (no transparency) — Downloads the PNG
  • Save as SVG — Downloads the SVG file
  • Open as image in new tab — Opens the SVG in a new browser tab
  • Open source in new tab — Opens the raw source in a new tab
  • Show default browser menu — Displays a toast instruction to right-click outside the diagram

HTML Content Menu Items

For HTML-based content (flamechart, calltree):

  • Copy as PNG — Renders the HTML element to a canvas via foreignObject and copies to clipboard
  • Save as PNG — Downloads the rendered PNG
  • Show default browser menu — Displays a toast instruction

Z-Index

The context menu renders at z-index: 20001 to appear above internal flow popup overlays (z-index: 20000).

Home


Demo


Getting Started

Common Tasks

Integration Guides

Extensions

Configuration

Features

Reference

Clone this wiki locally