IRONSOFTWAREHOME
MIGRATION GUIDES

How to Migrate from VectSharp to IronPDF in C#

Curtis Chau
Curtis Chau
Updated: August 1, 2026

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

IronPDF 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 vs VectSharp: Feature Comparison

Understanding the architectural differences helps technical decision-makers evaluate the migration investment:

FeatureVectSharpIronPDF
Primary UseVector GraphicsDocument Creation
PDF OutputYesYes
HTML SupportNoYes
LicensingLGPL-3.0-onlyCommercial
Open SourceYesPartially (commercial features)
Best ForScientific VisualizationsGeneral PDF Documents
CustomizationLimited to GraphicsExtensive, Document-Related
HTML to PDFNoFull Chromium
URL to PDFNoYes
CSS SupportNoFull CSS3
JavaScriptNoFull ES2024
Automatic LayoutNoYes
Automatic Page BreaksNoYes
Text WrappingManualAutomatic
Merge PDFsNoYes
Split PDFsNoYes
Password ProtectionNoYes
Digital SignaturesNoYes
Learning CurveHigh (coordinates)Low (HTML/CSS)
Code VerbosityVery HighLow

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
SHELL

Install IronPDF:

# Install IronPDF
dotnet add package IronPdf
SHELL

Step 2: Update Namespaces

Replace VectSharp namespaces with the IronPDF namespace:

// Before (VectSharp)
using VectSharp;
using VectSharp.PDF;

// After (IronPDF)
using IronPdf;

Step 3: Initialize License

Add license initialization at application startup:

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");
    }
}
C#

IronPDF 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");
    }
}

VectSharp 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");
    }
}
C#

IronPDF 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");
    }
}

VectSharp 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");
    }
}
C#

IronPDF 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");
    }
}

VectSharp 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:

VectSharpIronPDF
DocumentChromePdfRenderer
PageAutomatic
GraphicsHTML/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
GraphicsPathSVG <path> element
Colour.FromRgb()CSS color values
Font / FontFamilyCSS font-family
doc.SaveAsPDF()pdf.SaveAs()
Manual page sizingRenderingOptions.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>

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>

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);

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;
}
Text

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>
HTML

Issue 3: Color Handling

VectSharp uses Colour.FromRgb() method calls.

Solution: Use CSS colors:

.header { color: rgb(0, 102, 204); background-color: #f0f0f0; }
Text

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>
HTML

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" .
SHELL

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

  1. Remove VectSharp NuGet packages
  2. Install IronPDF NuGet package
  3. Update using statements from VectSharp to IronPdf
  4. Convert FillRectangle calls to CSS boxes with background-color
  5. Convert FillText calls to HTML text elements with CSS styling
  6. Convert GraphicsPath operations to SVG <path> elements
  7. Replace manual page management with RenderingOptions.PaperSize
  8. 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.

Please note: VectSharp is a registered trademark of its respective owner. This site is not affiliated with, endorsed by, or sponsored by VectSharp. All product names, logos, and brands are property of their respective owners. Comparisons are for informational purposes only and reflect publicly available information at the time of writing.
Curtis Chau
Technical Writer

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.

...
Read More

Related Articles

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required