How to convert SqlScript to Svg
How to Convert an SqlScript File to an Svg Image
Sheetize provides a simple, high‑performance API that lets you turn a SQL script file (.sqlscript) into a crisp SVG (Scalable Vector Graphics) picture. This is perfect for visualizing database schemas, embedding query results in documentation, or creating vector‑based diagrams that scale without loss.
Why Use Sheetize for SqlScript‑to‑Svg Conversion?
- Full fidelity – retains all SQL keywords, formatting, and comment highlighting while producing a clean vector graphic.
- Fast & scalable – optimized for .NET, works on Windows, macOS, and Linux.
- Customizable styling – control font, colors, and line spacing to match your branding.
- Zero‑dependency – no external tools or Office installations required.
Getting Started
Add the Sheetize.ImageConverter package to your .NET project (via NuGet) and call the ImageConverter.Process method.
Sample C# Code
using Sheetize;
var loadOptions = new LoadOptions
{
// Path to the source SqlScript file
InputFile = @"D:\Database\CreateSchema.sqlscript"
};
var saveOptions = new ImageSaveOptions
{
// Desired output file – SVG extension selects the SVG format
OutputFile = @"D:\Diagrams\CreateSchema.svg",
// Optional: control image styling
FontName = "Consolas",
FontSize = 12,
// Optional: set a dark or light theme (BackgroundColor = "#FFFFFF" for light)
BackgroundColor = "#FFFFFF"
};
ImageConverter.Process(loadOptions, saveOptions);The snippet loads CreateSchema.sqlscript and writes CreateSchema.svg using the specified font and background settings.
Key Options for Svg Output
- FontName / FontSize – define the typeface and size used for the rendered SQL text.
- BackgroundColor – set a background fill; transparent by default if omitted.
- LineHeight – adjust vertical spacing between lines (e.g.,
1.2for 120 %). - SyntaxHighlighting – enable or disable colored keywords (via additional API flags).
Best Practices
- Choose a monospaced font (e.g., Consolas, Courier New) for the best readability.
- Use a light background for printed material and a dark background for on‑screen presentations.
- After generating the SVG, open it in a vector‑graphics viewer (e.g., Inkscape, Chrome) to verify that all characters render correctly and the file scales as expected.