A specialized utility for converting StarUML-generated SVG diagrams into a format compatible with Microsoft Word, specifically designed for ISO document preparation.
This tool addresses critical compatibility issues when importing StarUML SVG diagrams into Microsoft Word:
- Removes Word-incompatible SVG attributes that cause Word's parser to fail (e.g.,
paint-order,vector-effect) - Preserves UML class borders and structure (shadows, fills, and path-based borders)
- Flattens transform matrices to ensure proper positioning in Word
- Changes fonts from Arial to Cambria (or custom font) for ISO document compliance
- Adds viewBox attributes for proper scaling
- Cleans up problematic elements while maintaining diagram integrity
StarUML exports SVG files using modern SVG 2.0 features that Microsoft Word doesn't fully support. Without processing, Word will either:
- Stop parsing after the first few elements
- Display diagrams with missing borders
- Fail to import the SVG entirely
This tool bridges the gap, making StarUML diagrams fully compatible with Word's SVG import capabilities.
✅ Word Compatibility
- Removes
paint-orderattributes that break Word's SVG parser - Removes
vector-effectand other unsupported attributes - Cleans up empty
stroke-dasharrayattributes
✅ Preserves Diagram Structure
- Maintains UML class borders (rendered as
<path>elements) - Preserves shadows (rectangles with opacity)
- Keeps all structural elements intact
✅ Transform Management
- Applies and flattens common transform matrices
- Converts matrix transforms to absolute coordinates
- Ensures proper positioning in Word
✅ Font Conversion
- Converts Arial to Cambria (default for ISO documents)
- Supports custom target font via command-line parameter
- Maintains text positioning and styling
✅ Safe Operation
- Creates
.backupfiles before modifying - Validates XML structure
- Provides detailed processing logs
Process all SVG files in the current directory:
CleanSVG.exeProcess SVG files in a specific directory:
CleanSVG.exe "C:\Path\To\Your\SVG\Files"Convert fonts to a specific typeface:
CleanSVG.exe "C:\Path\To\SVG\Files" --font "Times New Roman"Or using short form:
CleanSVG.exe "C:\Path\To\SVG\Files" -f "Calibri"Process files without changing fonts:
CleanSVG.exe "C:\Path\To\SVG\Files" --no-font-changeUse . to explicitly specify the current directory:
CleanSVG.exe . --font "Arial"| Parameter | Description | Default |
|---|---|---|
[directory] |
Path to directory containing SVG files | Current directory |
--font <name> or -f <name> |
Target font family for conversion | Cambria |
--no-font-change |
Skip font conversion entirely | (font change enabled) |
--help, -h, -? |
Display help message | - |
The tool performs the following operations on each SVG file:
- ViewBox Addition: Adds
viewBoxattribute if missing for proper scaling - Debug Cleanup: Removes any debug backgrounds from previous runs
- Transform Flattening: Applies and removes transform matrices
- Attribute Cleaning: Removes Word-incompatible attributes
- Rectangle Filtering: Removes only transparent overlays (preserves structural rectangles)
- Font Conversion: Changes font families (default: Arial → Cambria)
- Empty Group Removal: Cleans up empty
<g>elements - Backup Creation: Saves original as
filename.svg.backup
The tool provides detailed console output:
CleanSVG - StarUML to Microsoft Word SVG Converter
===================================================
Directory: C:\My\SVG\Files
Target font: Cambria
Found 5 SVG files to process...
Processing: ClassDiagram1.svg
Added viewBox: 0 0 800 600
Fonts changed (Arial → Cambria): 23
Transforms applied: 15
Word-incompatible attributes cleaned: 8
Empty elements removed: 3
✓ Modified and saved
=== Summary ===
Files processed: 5
Files modified: 5
Files unchanged: 0
- .NET 10 or later
- Windows operating system
- Microsoft Word 2016 or later (for importing processed SVGs)
- Design your UML diagrams in StarUML
- Export diagrams as SVG files to a directory
- Navigate to that directory in command prompt/terminal
- Run
CleanSVG.exe(or specify the directory) - Import the processed SVG files into Microsoft Word
- Use in your ISO documentation
Cambria is the default font for ISO documents and technical documentation because:
- It's optimized for on-screen reading
- Includes comprehensive Unicode coverage
- Maintains clarity at small sizes
- Is a standard Microsoft Office font
StarUML generates SVG with the following structure for UML classes:
<g><!-- Shadow --><rect fill="#C0C0C0" fill-opacity="0.2" .../></g>
<g><!-- Background --><rect fill="#ffffff" stroke="none" .../></g>
<g><!-- Border --><path stroke="#000000" d="M ... Z" /></g>
<g><!-- Text --><text>ClassName</text></g>This tool preserves all these elements while making them Word-compatible.
Original files are preserved as filename.svg.backup (created only once, never overwritten). To restore originals:
# Windows PowerShell
Get-ChildItem *.backup | ForEach-Object { Copy-Item $_ ($_.Name -replace '\.backup$','') }- Ensure you're in the correct directory or specify the full path
- Check that files have the
.svgextension - Verify the directory exists
- Verify the SVG opens correctly in a web browser
- Check that the file isn't corrupted
- Ensure Word supports SVG import (Word 2016+)
- Check the console output for "Rectangles removed" count
- Verify the source SVG has
<path>elements withstrokeattributes - Run with the latest version of CleanSVG
- Verify the
--fontparameter is spelled correctly - Check console output for "Fonts changed" count
- Ensure source SVG uses Arial or the expected source font
# Process current directory with default settings
CleanSVG.exe
# Process specific directory
CleanSVG.exe "D:\Projects\UML\Diagrams"
# Custom font for specific ISO standard
CleanSVG.exe "D:\ISO-27001\Diagrams" --font "Times New Roman"
# Keep original Arial fonts
CleanSVG.exe . --no-font-change
# Show help
CleanSVG.exe --helpThis tool is provided as-is for processing StarUML SVG files for ISO documentation purposes.
Developed for the ContSys 2026 FDIS documentation project.
- Removed hard-coded directory path
- Default to current directory
- Added check for no SVG files found
- Improved error messages
- Initial release
- Word compatibility fixes
- Transform flattening
- Configurable font conversion
- Comprehensive backup system
For ISO Documentation Teams: This tool is specifically designed to maintain diagram quality and consistency when transitioning from design tools to formal documentation in Microsoft Word.