
How to Migrate from VectSharp to IronPDF in C#
VectSharp (by Giorgio Bianchini, arklumpus/VectSharp) is a light cross-platform vector graphics library for .NET Standard 2.0, often used for scientific visualization and technical illustrations. When development teams need to generate business documents, reports, invoices, or HTML-based content, VectSharp's graphics-first paradigm creates friction. It is designed for figures and plots, not for 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 vector graphics library designed for creating diagrams, charts, and technical illustrations, with pluggable output layers including VectSharp.PDF, VectSharp.SVG, and VectSharp.Raster. It's not designed for document generation - it's a drawing library whose VectSharp.PDF package adds a SaveAsPDF extension method on Document. 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(FontFamily.ResolveFontFamily(FontFamily.StandardFontFamilies.Helvetica), 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(FontFamily.ResolveFontFamily(FontFamily.StandardFontFamilies.Helvetica), 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(FontFamily.ResolveFontFamily(FontFamily.StandardFontFamilies.Helvetica), 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);' IronPDF: Declarative HTML for document creation
Dim html As String = "<h1>Invoice</h1><p>Customer: Acme Corp</p>"
Dim pdf = renderer.RenderHtmlAsPdf(html)' IronPDF: Declarative HTML for document creation
Dim html As String = "<h1>Invoice</h1><p>Customer: Acme Corp</p>"
Dim pdf = renderer.RenderHtmlAsPdf(html)IronPDF 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-3.0-only | 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 (PDF first, then core)
dotnet remove package VectSharp.PDF
dotnet remove package VectSharp
Install IronPDF:
# Install IronPDF
dotnet add package IronPdf
Step 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;Imports IronPdfImports IronPdfStep 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"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),
Colours.Black);
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),
Colours.Black);
doc.Pages.Add(page);
doc.SaveAsPDF("output.pdf");
}
}Imports VectSharp
Imports VectSharp.PDF
Imports VectSharp.SVG
Imports System.IO
Class Program
Shared Sub Main()
' VectSharp doesn't directly support HTML to PDF
' It requires manual creation of graphics objects
Dim doc As New Document()
Dim page As New Page(595, 842) ' A4 size
Dim graphics As Graphics = page.Graphics
graphics.FillText(100, 100, "Hello from VectSharp",
New Font(FontFamily.ResolveFontFamily(FontFamily.StandardFontFamilies.Helvetica), 24),
Colours.Black)
doc.Pages.Add(page)
doc.SaveAsPDF("output.pdf")
End Sub
End ClassImports VectSharp
Imports VectSharp.PDF
Imports VectSharp.SVG
Imports System.IO
Class Program
Shared Sub Main()
' VectSharp doesn't directly support HTML to PDF
' It requires manual creation of graphics objects
Dim doc As New Document()
Dim page As New Page(595, 842) ' A4 size
Dim graphics As Graphics = page.Graphics
graphics.FillText(100, 100, "Hello from VectSharp",
New Font(FontFamily.ResolveFontFamily(FontFamily.StandardFontFamilies.Helvetica), 24),
Colours.Black)
doc.Pages.Add(page)
doc.SaveAsPDF("output.pdf")
End Sub
End ClassIronPDF 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");
}
}Imports IronPdf
Class Program
Shared Sub Main()
Dim renderer = New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf("<h1>Hello from IronPDF</h1><p>This is HTML content.</p>")
pdf.SaveAs("output.pdf")
End Sub
End ClassImports IronPdf
Class Program
Shared Sub Main()
Dim renderer = New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf("<h1>Hello from IronPDF</h1><p>This is HTML content.</p>")
pdf.SaveAs("output.pdf")
End Sub
End ClassVectSharp 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();
FontFamily helvetica =
FontFamily.ResolveFontFamily(FontFamily.StandardFontFamilies.Helvetica);
Font titleFont = new Font(helvetica, 24);
Font bodyFont = new Font(helvetica, 14);
// Page 1
Page page1 = new Page(595, 842);
Graphics g1 = page1.Graphics;
g1.FillText(50, 50, "Page 1", titleFont, Colours.Black);
g1.FillText(50, 100, "First page content", bodyFont, Colours.Black);
doc.Pages.Add(page1);
// Page 2
Page page2 = new Page(595, 842);
Graphics g2 = page2.Graphics;
g2.FillText(50, 50, "Page 2", titleFont, Colours.Black);
g2.FillText(50, 100, "Second page content", bodyFont, Colours.Black);
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();
FontFamily helvetica =
FontFamily.ResolveFontFamily(FontFamily.StandardFontFamilies.Helvetica);
Font titleFont = new Font(helvetica, 24);
Font bodyFont = new Font(helvetica, 14);
// Page 1
Page page1 = new Page(595, 842);
Graphics g1 = page1.Graphics;
g1.FillText(50, 50, "Page 1", titleFont, Colours.Black);
g1.FillText(50, 100, "First page content", bodyFont, Colours.Black);
doc.Pages.Add(page1);
// Page 2
Page page2 = new Page(595, 842);
Graphics g2 = page2.Graphics;
g2.FillText(50, 50, "Page 2", titleFont, Colours.Black);
g2.FillText(50, 100, "Second page content", bodyFont, Colours.Black);
doc.Pages.Add(page2);
doc.SaveAsPDF("multipage.pdf");
}
}Imports VectSharp
Imports VectSharp.PDF
Imports System
Class Program
Shared Sub Main()
Dim doc As New Document()
Dim helvetica As FontFamily = FontFamily.ResolveFontFamily(FontFamily.StandardFontFamilies.Helvetica)
Dim titleFont As New Font(helvetica, 24)
Dim bodyFont As New Font(helvetica, 14)
' Page 1
Dim page1 As New Page(595, 842)
Dim g1 As Graphics = page1.Graphics
g1.FillText(50, 50, "Page 1", titleFont, Colours.Black)
g1.FillText(50, 100, "First page content", bodyFont, Colours.Black)
doc.Pages.Add(page1)
' Page 2
Dim page2 As New Page(595, 842)
Dim g2 As Graphics = page2.Graphics
g2.FillText(50, 50, "Page 2", titleFont, Colours.Black)
g2.FillText(50, 100, "Second page content", bodyFont, Colours.Black)
doc.Pages.Add(page2)
doc.SaveAsPDF("multipage.pdf")
End Sub
End ClassImports VectSharp
Imports VectSharp.PDF
Imports System
Class Program
Shared Sub Main()
Dim doc As New Document()
Dim helvetica As FontFamily = FontFamily.ResolveFontFamily(FontFamily.StandardFontFamilies.Helvetica)
Dim titleFont As New Font(helvetica, 24)
Dim bodyFont As New Font(helvetica, 14)
' Page 1
Dim page1 As New Page(595, 842)
Dim g1 As Graphics = page1.Graphics
g1.FillText(50, 50, "Page 1", titleFont, Colours.Black)
g1.FillText(50, 100, "First page content", bodyFont, Colours.Black)
doc.Pages.Add(page1)
' Page 2
Dim page2 As New Page(595, 842)
Dim g2 As Graphics = page2.Graphics
g2.FillText(50, 50, "Page 2", titleFont, Colours.Black)
g2.FillText(50, 100, "Second page content", bodyFont, Colours.Black)
doc.Pages.Add(page2)
doc.SaveAsPDF("multipage.pdf")
End Sub
End ClassIronPDF 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");
}
}' NuGet: Install-Package IronPdf
Imports IronPdf
Module Program
Sub Main()
Dim renderer = New ChromePdfRenderer()
Dim html As String = "
<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>
"
Dim pdf = renderer.RenderHtmlAsPdf(html)
pdf.SaveAs("multipage.pdf")
End Sub
End Module' NuGet: Install-Package IronPdf
Imports IronPdf
Module Program
Sub Main()
Dim renderer = New ChromePdfRenderer()
Dim html As String = "
<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>
"
Dim pdf = renderer.RenderHtmlAsPdf(html)
pdf.SaveAs("multipage.pdf")
End Sub
End ModuleVectSharp 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 - FillText requires a colour parameter
graphics.FillText(50, 200, "VectSharp Graphics",
new Font(FontFamily.ResolveFontFamily(FontFamily.StandardFontFamilies.Helvetica), 20),
Colours.Black);
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 - FillText requires a colour parameter
graphics.FillText(50, 200, "VectSharp Graphics",
new Font(FontFamily.ResolveFontFamily(FontFamily.StandardFontFamilies.Helvetica), 20),
Colours.Black);
doc.Pages.Add(page);
doc.SaveAsPDF("shapes.pdf");
}
}' NuGet: Install-Package VectSharp.PDF
Imports VectSharp
Imports VectSharp.PDF
Imports System
Module Program
Sub Main()
Dim doc As New Document()
Dim page As New Page(595, 842)
Dim graphics As Graphics = page.Graphics
' Draw rectangle
graphics.FillRectangle(50, 50, 200, 100, Colour.FromRgb(0, 0, 255))
' Draw circle
Dim circle As New GraphicsPath()
circle.Arc(400, 100, 50, 0, 2 * Math.PI)
graphics.FillPath(circle, Colour.FromRgb(255, 0, 0))
' Add text - FillText requires a colour parameter
graphics.FillText(50, 200, "VectSharp Graphics", New Font(FontFamily.ResolveFontFamily(FontFamily.StandardFontFamilies.Helvetica), 20), Colours.Black)
doc.Pages.Add(page)
doc.SaveAsPDF("shapes.pdf")
End Sub
End Module' NuGet: Install-Package VectSharp.PDF
Imports VectSharp
Imports VectSharp.PDF
Imports System
Module Program
Sub Main()
Dim doc As New Document()
Dim page As New Page(595, 842)
Dim graphics As Graphics = page.Graphics
' Draw rectangle
graphics.FillRectangle(50, 50, 200, 100, Colour.FromRgb(0, 0, 255))
' Draw circle
Dim circle As New GraphicsPath()
circle.Arc(400, 100, 50, 0, 2 * Math.PI)
graphics.FillPath(circle, Colour.FromRgb(255, 0, 0))
' Add text - FillText requires a colour parameter
graphics.FillText(50, 200, "VectSharp Graphics", New Font(FontFamily.ResolveFontFamily(FontFamily.StandardFontFamilies.Helvetica), 20), Colours.Black)
doc.Pages.Add(page)
doc.SaveAsPDF("shapes.pdf")
End Sub
End ModuleIronPDF 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");
}
}' NuGet: Install-Package IronPdf
Imports IronPdf
Imports IronPdf.Rendering
Module Program
Sub Main()
Dim renderer As New ChromePdfRenderer()
Dim html As String = "
<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>
"
Dim pdf = renderer.RenderHtmlAsPdf(html)
pdf.SaveAs("shapes.pdf")
End Sub
End Module' NuGet: Install-Package IronPdf
Imports IronPdf
Imports IronPdf.Rendering
Module Program
Sub Main()
Dim renderer As New ChromePdfRenderer()
Dim html As String = "
<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>
"
Dim pdf = renderer.RenderHtmlAsPdf(html)
pdf.SaveAs("shapes.pdf")
End Sub
End ModuleVectSharp 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>' 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>' 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);Dim html As String = "
<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>"
Dim renderer As New ChromePdfRenderer()
renderer.RenderingOptions.EnableJavaScript = True
Dim pdf = renderer.RenderHtmlAsPdf(html)Dim html As String = "
<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>"
Dim renderer As New ChromePdfRenderer()
renderer.RenderingOptions.EnableJavaScript = True
Dim pdf = renderer.RenderHtmlAsPdf(html)Common 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>
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>
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" .
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: IronPDF's regular updates ensure compatibility with current and future .NET versions.
Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.
Related Articles


