How to Migrate from VectSharp to IronPDF in C#
VectSharp has established itself as a capable vector graphics library in the .NET ecosystem, particularly valued for scientific visualization and technical illustrations. However, when development teams need to generate business documents, reports, invoices, or any HTML-based content, VectSharp's graphics-first paradigm creates significant friction. The library is designed for scientists creating figures and plots, not for developers generating documents.
This guide provides a complete migration path from VectSharp to IronPDF, with step-by-step instructions, code comparisons, and practical examples for professional .NET developers evaluating this transition.
Why Migrate from VectSharp
VectSharp is a scientific visualization and vector graphics library designed for creating diagrams, charts, and technical illustrations. It's not designed for document generation—it's a drawing library that happens to output PDF. Key reasons development teams consider migration include:
Scientific Focus Only: VectSharp is designed for data visualization and plotting, not business documents like invoices, reports, or certificates.
No HTML Support: VectSharp cannot convert HTML or CSS to PDF. Every element must be drawn manually using vector graphics commands.
Coordinate-Based API: Every element must be positioned with exact X,Y coordinates. There's no automatic layout, flow, or text wrapping.
No CSS Styling: All styling is programmatic through method calls. Web developers cannot leverage their existing CSS knowledge.
No JavaScript: VectSharp cannot render dynamic web content, interactive charts, or JavaScript-based visualizations.
No Text Layout: Automatic text wrapping, pagination, and flow layout are not available. Developers must manually calculate text positions and page breaks.
Graphics-First Paradigm: The library is designed for diagrams, not reports or invoices. Document generation requires extensive manual work.
The Core Problem: Graphics Library vs Document Generator
VectSharp requires manual vector drawing for every element:
// VectSharp: Manual vector drawing for every element
Page page = new Page(595, 842);
Graphics graphics = page.Graphics;
graphics.FillRectangle(50, 50, 200, 100, Colour.FromRgb(0, 0, 255));
graphics.FillText(60, 70, "Invoice", new Font(new FontFamily("Arial"), 20), Colours.White);
// ... continue drawing every single element manually// VectSharp: Manual vector drawing for every element
Page page = new Page(595, 842);
Graphics graphics = page.Graphics;
graphics.FillRectangle(50, 50, 200, 100, Colour.FromRgb(0, 0, 255));
graphics.FillText(60, 70, "Invoice", new Font(new FontFamily("Arial"), 20), Colours.White);
// ... continue drawing every single element manually' VectSharp: Manual vector drawing for every element
Dim page As New Page(595, 842)
Dim graphics As Graphics = page.Graphics
graphics.FillRectangle(50, 50, 200, 100, Colour.FromRgb(0, 0, 255))
graphics.FillText(60, 70, "Invoice", New Font(New FontFamily("Arial"), 20), Colours.White)
' ... continue drawing every single element manuallyIronPDF uses HTML—the universal document format:
// IronPDF: Declarative HTML for document creation
var html = "<h1>Invoice</h1><p>Customer: Acme Corp</p>";
var pdf = renderer.RenderHtmlAsPdf(html);// IronPDF: Declarative HTML for document creation
var html = "<h1>Invoice</h1><p>Customer: Acme Corp</p>";
var pdf = renderer.RenderHtmlAsPdf(html);IRON VB CONVERTER ERROR developers@ironsoftware.comIronPDF vs VectSharp: Feature Comparison
Understanding the architectural differences helps technical decision-makers evaluate the migration investment:
| Feature | VectSharp | IronPDF |
|---|---|---|
| Primary Use | Vector Graphics | Document Creation |
| PDF Output | Yes | Yes |
| HTML Support | No | Yes |
| Licensing | LGPL | Commercial |
| Open Source | Yes | Partially (commercial features) |
| Best For | Scientific Visualizations | General PDF Documents |
| Customization | Limited to Graphics | Extensive, Document-Related |
| HTML to PDF | No | Full Chromium |
| URL to PDF | No | Yes |
| CSS Support | No | Full CSS3 |
| JavaScript | No | Full ES2024 |
| Automatic Layout | No | Yes |
| Automatic Page Breaks | No | Yes |
| Text Wrapping | Manual | Automatic |
| Merge PDFs | No | Yes |
| Split PDFs | No | Yes |
| Password Protection | No | Yes |
| Digital Signatures | No | Yes |
| Learning Curve | High (coordinates) | Low (HTML/CSS) |
| Code Verbosity | Very High | Low |
Quick Start: VectSharp to IronPDF Migration
The migration can begin immediately with these foundational steps.
Step 1: Replace NuGet Packages
Remove all VectSharp packages:
# Remove VectSharp packages
dotnet remove package VectSharp
dotnet remove package VectSharp.PDF# Remove VectSharp packages
dotnet remove package VectSharp
dotnet remove package VectSharp.PDFInstall IronPDF:
# Install IronPDF
dotnet add package IronPdf# Install IronPDF
dotnet add package IronPdfStep 2: Update Namespaces
Replace VectSharp namespaces with the IronPdf namespace:
// Before (VectSharp)
using VectSharp;
using VectSharp.PDF;
// After (IronPDF)
using IronPdf;// Before (VectSharp)
using VectSharp;
using VectSharp.PDF;
// After (IronPDF)
using IronPdf;IRON VB CONVERTER ERROR developers@ironsoftware.comStep 3: Initialize License
Add license initialization at application startup:
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"Code Migration Examples
Converting HTML to PDF
VectSharp doesn't support HTML-to-PDF conversion. This fundamental capability difference drives many migration decisions.
VectSharp Approach:
// NuGet: Install-Package VectSharp.PDF
using VectSharp;
using VectSharp.PDF;
using VectSharp.SVG;
using System.IO;
class Program
{
static void Main()
{
// VectSharp doesn't directly support HTML to PDF
// It requires manual creation of graphics objects
Document doc = new Document();
Page page = new Page(595, 842); // A4 size
Graphics graphics = page.Graphics;
graphics.FillText(100, 100, "Hello from VectSharp",
new Font(FontFamily.ResolveFontFamily(FontFamily.StandardFontFamilies.Helvetica), 24));
doc.Pages.Add(page);
doc.SaveAsPDF("output.pdf");
}
}// NuGet: Install-Package VectSharp.PDF
using VectSharp;
using VectSharp.PDF;
using VectSharp.SVG;
using System.IO;
class Program
{
static void Main()
{
// VectSharp doesn't directly support HTML to PDF
// It requires manual creation of graphics objects
Document doc = new Document();
Page page = new Page(595, 842); // A4 size
Graphics graphics = page.Graphics;
graphics.FillText(100, 100, "Hello from VectSharp",
new Font(FontFamily.ResolveFontFamily(FontFamily.StandardFontFamilies.Helvetica), 24));
doc.Pages.Add(page);
doc.SaveAsPDF("output.pdf");
}
}IRON VB CONVERTER ERROR developers@ironsoftware.comIronPDF Approach:
// NuGet: Install-Package IronPdf
using IronPdf;
class Program
{
static void Main()
{
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello from IronPDF</h1><p>This is HTML content.</p>");
pdf.SaveAs("output.pdf");
}
}// NuGet: Install-Package IronPdf
using IronPdf;
class Program
{
static void Main()
{
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello from IronPDF</h1><p>This is HTML content.</p>");
pdf.SaveAs("output.pdf");
}
}IRON VB CONVERTER ERROR developers@ironsoftware.comVectSharp requires creating a Document, Page, and Graphics object, then manually positioning text with exact coordinates and font objects. IronPDF renders HTML directly with full CSS styling support.
For advanced HTML-to-PDF scenarios, see the HTML to PDF conversion guide.
Creating Multi-Page Documents
Multi-page documents reveal the architectural differences between these .NET PDF libraries.
VectSharp Approach:
// NuGet: Install-Package VectSharp.PDF
using VectSharp;
using VectSharp.PDF;
using System;
class Program
{
static void Main()
{
Document doc = new Document();
// Page 1
Page page1 = new Page(595, 842);
Graphics g1 = page1.Graphics;
g1.FillText(50, 50, "Page 1",
new Font(FontFamily.ResolveFontFamily(FontFamily.StandardFontFamilies.Helvetica), 24));
g1.FillText(50, 100, "First page content",
new Font(FontFamily.ResolveFontFamily(FontFamily.StandardFontFamilies.Helvetica), 14));
doc.Pages.Add(page1);
// Page 2
Page page2 = new Page(595, 842);
Graphics g2 = page2.Graphics;
g2.FillText(50, 50, "Page 2",
new Font(FontFamily.ResolveFontFamily(FontFamily.StandardFontFamilies.Helvetica), 24));
g2.FillText(50, 100, "Second page content",
new Font(FontFamily.ResolveFontFamily(FontFamily.StandardFontFamilies.Helvetica), 14));
doc.Pages.Add(page2);
doc.SaveAsPDF("multipage.pdf");
}
}// NuGet: Install-Package VectSharp.PDF
using VectSharp;
using VectSharp.PDF;
using System;
class Program
{
static void Main()
{
Document doc = new Document();
// Page 1
Page page1 = new Page(595, 842);
Graphics g1 = page1.Graphics;
g1.FillText(50, 50, "Page 1",
new Font(FontFamily.ResolveFontFamily(FontFamily.StandardFontFamilies.Helvetica), 24));
g1.FillText(50, 100, "First page content",
new Font(FontFamily.ResolveFontFamily(FontFamily.StandardFontFamilies.Helvetica), 14));
doc.Pages.Add(page1);
// Page 2
Page page2 = new Page(595, 842);
Graphics g2 = page2.Graphics;
g2.FillText(50, 50, "Page 2",
new Font(FontFamily.ResolveFontFamily(FontFamily.StandardFontFamilies.Helvetica), 24));
g2.FillText(50, 100, "Second page content",
new Font(FontFamily.ResolveFontFamily(FontFamily.StandardFontFamilies.Helvetica), 14));
doc.Pages.Add(page2);
doc.SaveAsPDF("multipage.pdf");
}
}IRON VB CONVERTER ERROR developers@ironsoftware.comIronPDF Approach:
// NuGet: Install-Package IronPdf
using IronPdf;
class Program
{
static void Main()
{
var renderer = new ChromePdfRenderer();
string html = @"
<h1>Page 1</h1>
<p>First page content</p>
<div style='page-break-after: always;'></div>
<h1>Page 2</h1>
<p>Second page content</p>
";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("multipage.pdf");
}
}// NuGet: Install-Package IronPdf
using IronPdf;
class Program
{
static void Main()
{
var renderer = new ChromePdfRenderer();
string html = @"
<h1>Page 1</h1>
<p>First page content</p>
<div style='page-break-after: always;'></div>
<h1>Page 2</h1>
<p>Second page content</p>
";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("multipage.pdf");
}
}IRON VB CONVERTER ERROR developers@ironsoftware.comVectSharp requires creating separate Page objects, separate Graphics contexts, and manually positioning every text element with coordinates and font objects for each page. IronPDF uses a single HTML string with CSS page-break-after: always to create multi-page documents automatically.
Drawing Shapes and Text
Graphics capabilities show where VectSharp excels—but also where web standards provide equivalent functionality with less code.
VectSharp Approach:
// NuGet: Install-Package VectSharp.PDF
using VectSharp;
using VectSharp.PDF;
using System;
class Program
{
static void Main()
{
Document doc = new Document();
Page page = new Page(595, 842);
Graphics graphics = page.Graphics;
// Draw rectangle
graphics.FillRectangle(50, 50, 200, 100, Colour.FromRgb(0, 0, 255));
// Draw circle
GraphicsPath circle = new GraphicsPath();
circle.Arc(400, 100, 50, 0, 2 * Math.PI);
graphics.FillPath(circle, Colour.FromRgb(255, 0, 0));
// Add text
graphics.FillText(50, 200, "VectSharp Graphics",
new Font(FontFamily.ResolveFontFamily(FontFamily.StandardFontFamilies.Helvetica), 20));
doc.Pages.Add(page);
doc.SaveAsPDF("shapes.pdf");
}
}// NuGet: Install-Package VectSharp.PDF
using VectSharp;
using VectSharp.PDF;
using System;
class Program
{
static void Main()
{
Document doc = new Document();
Page page = new Page(595, 842);
Graphics graphics = page.Graphics;
// Draw rectangle
graphics.FillRectangle(50, 50, 200, 100, Colour.FromRgb(0, 0, 255));
// Draw circle
GraphicsPath circle = new GraphicsPath();
circle.Arc(400, 100, 50, 0, 2 * Math.PI);
graphics.FillPath(circle, Colour.FromRgb(255, 0, 0));
// Add text
graphics.FillText(50, 200, "VectSharp Graphics",
new Font(FontFamily.ResolveFontFamily(FontFamily.StandardFontFamilies.Helvetica), 20));
doc.Pages.Add(page);
doc.SaveAsPDF("shapes.pdf");
}
}IRON VB CONVERTER ERROR developers@ironsoftware.comIronPDF Approach:
// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Rendering;
class Program
{
static void Main()
{
var renderer = new ChromePdfRenderer();
string html = @"
<div style='width: 200px; height: 100px; background-color: blue; margin: 50px;'></div>
<div style='width: 100px; height: 100px; background-color: red;
border-radius: 50%; margin-left: 350px; margin-top: -50px;'></div>
<h2 style='margin-left: 50px;'>IronPDF Graphics</h2>
";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("shapes.pdf");
}
}// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Rendering;
class Program
{
static void Main()
{
var renderer = new ChromePdfRenderer();
string html = @"
<div style='width: 200px; height: 100px; background-color: blue; margin: 50px;'></div>
<div style='width: 100px; height: 100px; background-color: red;
border-radius: 50%; margin-left: 350px; margin-top: -50px;'></div>
<h2 style='margin-left: 50px;'>IronPDF Graphics</h2>
";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("shapes.pdf");
}
}IRON VB CONVERTER ERROR developers@ironsoftware.comVectSharp requires creating GraphicsPath objects, calling Arc() with precise mathematical parameters, and managing colors through Colour.FromRgb(). IronPDF uses familiar CSS properties: background-color, border-radius: 50% for circles, and standard margins.
VectSharp API to IronPDF Mapping Reference
This mapping accelerates migration by showing direct API equivalents:
| VectSharp | IronPDF |
|---|---|
Document | ChromePdfRenderer |
Page | Automatic |
Graphics | HTML/CSS |
graphics.FillRectangle() | CSS background-color on <div> |
graphics.StrokeRectangle() | CSS border on <div> |
graphics.FillText() | HTML text elements |
graphics.StrokePath() | SVG or CSS borders |
GraphicsPath | SVG <path> element |
Colour.FromRgb() | CSS color values |
Font / FontFamily | CSS font-family |
doc.SaveAsPDF() | pdf.SaveAs() |
| Manual page sizing | RenderingOptions.PaperSize |
Migration Strategies
Strategy 1: Convert Drawing Code to HTML/CSS
Replace coordinate-based drawing with HTML elements:
// VectSharp
graphics.FillRectangle(100, 50, 300, 80, Colour.FromRgb(0, 102, 204));
graphics.FillText(110, 80, "Header", font, Colours.White);
// IronPDF HTML equivalent
<div style="
position: absolute;
left: 100px;
top: 50px;
width: 300px;
height: 80px;
background: rgb(0, 102, 204);
color: white;
padding: 10px;
">Header</div>// VectSharp
graphics.FillRectangle(100, 50, 300, 80, Colour.FromRgb(0, 102, 204));
graphics.FillText(110, 80, "Header", font, Colours.White);
// IronPDF HTML equivalent
<div style="
position: absolute;
left: 100px;
top: 50px;
width: 300px;
height: 80px;
background: rgb(0, 102, 204);
color: white;
padding: 10px;
">Header</div>' VectSharp
graphics.FillRectangle(100, 50, 300, 80, Colour.FromRgb(0, 102, 204))
graphics.FillText(110, 80, "Header", font, Colours.White)
' IronPDF HTML equivalent
<div style="
position: absolute;
left: 100px;
top: 50px;
width: 300px;
height: 80px;
background: rgb(0, 102, 204);
color: white;
padding: 10px;
">Header</div>Strategy 2: Use SVG for Vector Graphics
For complex shapes, use inline SVG in your HTML:
// VectSharp path
GraphicsPath path = new GraphicsPath();
path.MoveTo(100, 100);
path.LineTo(200, 50);
path.LineTo(300, 100);
path.Close();
graphics.FillPath(path, Colours.Blue);
// IronPDF SVG equivalent
<svg><polygon points="100,100 200,50 300,100" fill="blue"/></svg>// VectSharp path
GraphicsPath path = new GraphicsPath();
path.MoveTo(100, 100);
path.LineTo(200, 50);
path.LineTo(300, 100);
path.Close();
graphics.FillPath(path, Colours.Blue);
// IronPDF SVG equivalent
<svg><polygon points="100,100 200,50 300,100" fill="blue"/></svg>' VectSharp path
Dim path As New GraphicsPath()
path.MoveTo(100, 100)
path.LineTo(200, 50)
path.LineTo(300, 100)
path.Close()
graphics.FillPath(path, Colours.Blue)
' IronPDF SVG equivalent
<svg><polygon points="100,100 200,50 300,100" fill="blue"/></svg>Strategy 3: Use JavaScript Chart Libraries
For scientific visualizations—VectSharp's specialty—IronPDF can leverage powerful JavaScript libraries like Chart.js, D3.js, or Plotly:
var html = @"
<script src='https://cdn.plot.ly/plotly-latest.min.js'></script>
<div id='chart'></div>
<script>
Plotly.newPlot('chart', [{
x: [1, 2, 3, 4],
y: [10, 15, 13, 17],
type: 'scatter'
}]);
</script>";
var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.EnableJavaScript = true;
var pdf = renderer.RenderHtmlAsPdf(html);var html = @"
<script src='https://cdn.plot.ly/plotly-latest.min.js'></script>
<div id='chart'></div>
<script>
Plotly.newPlot('chart', [{
x: [1, 2, 3, 4],
y: [10, 15, 13, 17],
type: 'scatter'
}]);
</script>";
var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.EnableJavaScript = true;
var pdf = renderer.RenderHtmlAsPdf(html);IRON VB CONVERTER ERROR developers@ironsoftware.comCommon Migration Issues and Solutions
Issue 1: Coordinate System Differences
VectSharp uses points from top-left origin with manual positioning.
Solution: Use CSS positioning:
.element {
position: absolute;
top: 50px;
left: 100px;
}Issue 2: Font Objects
VectSharp creates Font and FontFamily objects programmatically.
Solution: Use CSS font-family:
<style>
body { font-family: Arial, sans-serif; font-size: 12pt; }
</style><style>
body { font-family: Arial, sans-serif; font-size: 12pt; }
</style>Issue 3: Color Handling
VectSharp uses Colour.FromRgb() method calls.
Solution: Use CSS colors:
.header { color: rgb(0, 102, 204); background-color: #f0f0f0; }Issue 4: Graphics Paths
VectSharp uses complex GraphicsPath API with MoveTo, LineTo, Arc methods.
Solution: Use SVG for vector graphics:
<svg>
<path d="M 100 100 L 200 50 L 300 100 Z" fill="blue"/>
</svg><svg>
<path d="M 100 100 L 200 50 L 300 100 Z" fill="blue"/>
</svg>VectSharp Migration Checklist
Pre-Migration Tasks
Audit your codebase to identify all VectSharp usage:
grep -r "using VectSharp" --include="*.cs" .
grep -r "Graphics\|FillRectangle\|FillText" --include="*.cs" .grep -r "using VectSharp" --include="*.cs" .
grep -r "Graphics\|FillRectangle\|FillText" --include="*.cs" .Document page sizes (the new Page(595, 842) patterns). Note color schemes using Colour.FromRgb(). Identify font configurations. Map complex vector graphics using GraphicsPath for SVG conversion.
Code Update Tasks
- Remove VectSharp NuGet packages
- Install IronPdf NuGet package
- Update using statements from
VectSharptoIronPdf - Convert
FillRectanglecalls to CSS boxes withbackground-color - Convert
FillTextcalls to HTML text elements with CSS styling - Convert
GraphicsPathoperations to SVG<path>elements - Replace manual page management with
RenderingOptions.PaperSize - Add license initialization at startup
Post-Migration Testing
After migration, verify these aspects:
- Compare visual output between VectSharp and IronPDF versions
- Verify colors match using CSS equivalents of
Colour.FromRgb()values - Check positioning accuracy for elements converted from coordinate-based placement
- Test page breaks for multi-page documents
- Verify vector graphics render correctly through SVG
Key Benefits of Migrating to IronPDF
Moving from VectSharp to IronPDF provides several advantages for document generation:
HTML-Based Content: Web developers can leverage existing HTML and CSS skills. No need to learn coordinate-based drawing APIs.
Automatic Layout: Text wrapping, pagination, and flow layout happen automatically. No manual calculation of element positions.
Modern CSS Support: Full CSS3 including Flexbox and Grid layouts. Responsive designs translate directly to PDF.
JavaScript Execution: Interactive charts with Chart.js, D3.js, or Plotly render correctly. Dynamic content works as expected.
URL-to-PDF: Capture any web page as a PDF—functionality not possible with VectSharp.
PDF Operations: Merge, split, add watermarks, password protection, and digital signatures are built-in features.
Lower Code Verbosity: HTML/CSS is declarative and readable. The same document requires significantly less code than VectSharp's imperative drawing approach.
Active Development: As .NET 10 and C# 14 adoption increases through 2026, IronPDF's regular updates ensure compatibility with current and future .NET versions.






