Skip to footer content
MIGRATION GUIDES

How to Migrate from Ghostscript GPL to IronPDF in C#

Migrating from Ghostscript GPL to IronPDF transforms your .NET PDF workflow from command-line process spawning and string-based switch manipulation to a type-safe, IntelliSense-enabled native .NET API. This guide provides a comprehensive, step-by-step migration path that eliminates AGPL licensing concerns and external binary dependencies for professional .NET developers.

Why Migrate from Ghostscript GPL to IronPDF

The Ghostscript GPL Challenges

Ghostscript GPL is a venerable PostScript/PDF interpreter with decades of history, but its use in modern .NET applications presents significant challenges:

  1. AGPL License Restrictions: Ghostscript GPL's AGPL license requires you to release your source code if you distribute software that uses it—unless you purchase an expensive commercial license from Artifex. This "viral" licensing model creates significant legal risk for proprietary applications.

  2. Command-Line Interface: Ghostscript GPL is fundamentally a command-line tool. Using it from C# requires spawning processes, passing string arguments, and parsing output—a fragile and error-prone approach.

  3. External Binary Dependency: You must install Ghostscript GPL separately, manage PATH variables, and ensure version compatibility across deployment environments. Different DLLs are required for 32-bit vs 64-bit (gsdll32.dll vs gsdll64.dll).

  4. No Native HTML-to-PDF: Ghostscript GPL cannot convert HTML to PDF directly. You need to first convert HTML to PostScript using another tool, then use Ghostscript GPL to convert PostScript to PDF—a multi-step pipeline with external dependencies.

  5. Complex Switch Syntax: Operations are controlled via cryptic command-line switches like -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=.... No IntelliSense, no type safety, and easy to mistype.

  6. Error Handling: Errors come through stderr as text strings, requiring parsing rather than structured exception handling.

  7. Process Management Overhead: Each operation spawns a separate process, adding overhead and complexity for error handling, timeouts, and resource cleanup.

Ghostscript GPL vs IronPDF Comparison

AspectGhostscript GPLIronPDF
LicenseAGPL (viral) or expensive commercialCommercial with clear terms
IntegrationCommand-line process spawningNative .NET library
API DesignString-based switchesTyped, IntelliSense-enabled API
Error HandlingParse stderr text.NET exceptions
HTML-to-PDFNot supported (need external tools)Built-in Chromium engine
DependenciesExternal binary installationSelf-contained NuGet package
DeploymentConfigure PATH, copy DLLsJust add NuGet reference
Thread SafetyProcess isolation onlyThread-safe by design
Modern .NETLimited supportFull .NET 6/7/8/9/10 support
Async SupportProcess-basedNative async/await

For teams planning .NET 10 and C# 14 adoption through 2025 and 2026, IronPDF provides a future-proof foundation that integrates natively with modern .NET patterns.


Migration Complexity Assessment

Estimated Effort by Feature

FeatureMigration ComplexityNotes
PDF to ImagesLowDirect API mapping
Merge PDFsLowSimpler with IronPDF
Compress PDFLowBuilt-in options
PDF OptimizationLowDifferent approach
EncryptionMediumDifferent API
Page ExtractionLow0-indexed vs 1-indexed
PostScript to PDFMedium-HighConvert PS → PDF first
Custom SwitchesMedium-HighResearch equivalent features

Paradigm Shift

The fundamental shift in this Ghostscript GPL migration is from command-line process execution to typed .NET API calls:

Ghostscript GPL:  "Pass these string switches to external process"
IronPDF:          "Call these methods on .NET objects"

Before You Start

Prerequisites

  1. .NET Version: IronPDF supports .NET Framework 4.6.2+ and .NET Core 2.0+ / .NET 5/6/7/8/9+
  2. License Key: Obtain your IronPDF license key from ironpdf.com
  3. Backup: Create a branch for migration work

Identify All Ghostscript GPL Usage

# Find all Ghostscript.NET references
grep -r "Ghostscript\.NET\|GhostscriptProcessor\|GhostscriptRasterizer\|gsdll" --include="*.cs" .

# Find direct process calls to Ghostscript
grep -r "gswin64c\|gswin32c\|gs\|ProcessStartInfo.*ghost" --include="*.cs" .

# Find package references
grep -r "Ghostscript" --include="*.csproj" .
# Find all Ghostscript.NET references
grep -r "Ghostscript\.NET\|GhostscriptProcessor\|GhostscriptRasterizer\|gsdll" --include="*.cs" .

# Find direct process calls to Ghostscript
grep -r "gswin64c\|gswin32c\|gs\|ProcessStartInfo.*ghost" --include="*.cs" .

# Find package references
grep -r "Ghostscript" --include="*.csproj" .
SHELL

NuGet Package Changes

# Remove Ghostscript.NET
dotnet remove package Ghostscript.NET

# Install IronPDF
dotnet add package IronPdf
# Remove Ghostscript.NET
dotnet remove package Ghostscript.NET

# Install IronPDF
dotnet add package IronPdf
SHELL

Remove Ghostscript GPL Dependencies

After migration:

  • Uninstall Ghostscript GPL from servers
  • Remove gsdll32.dll / gsdll64.dll from deployments
  • Remove PATH configuration for Ghostscript GPL
  • Remove any GhostscriptVersionInfo references

Quick Start Migration

Step 1: Update License Configuration

Before (Ghostscript GPL):

Ghostscript GPL under AGPL requires either source code disclosure or an expensive commercial license from Artifex.

After (IronPDF):

// Set once at application startup
IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY";
// Set once at application startup
IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY";
$vbLabelText   $csharpLabel

Step 2: Update Namespace Imports

// Before (Ghostscript GPL)
using Ghostscript.NET;
using Ghostscript.NET.Processor;
using Ghostscript.NET.Rasterizer;

// After (IronPDF)
using IronPdf;
// Before (Ghostscript GPL)
using Ghostscript.NET;
using Ghostscript.NET.Processor;
using Ghostscript.NET.Rasterizer;

// After (IronPDF)
using IronPdf;
$vbLabelText   $csharpLabel

Complete API Reference

Core Class Mapping

Ghostscript.NETIronPDFDescription
GhostscriptProcessorVarious PdfDocument methodsPDF processing
GhostscriptRasterizerPdfDocument.ToBitmap() / RasterizeToImageFiles()PDF to images
GhostscriptVersionInfoN/A (not needed)DLL location
GhostscriptStdION/A (use exceptions)I/O handling
Process + command-lineChromePdfRendererHTML to PDF

Command-Line Switch Mapping

Ghostscript GPL SwitchIronPDF EquivalentDescription
-dNOPAUSEN/A (not needed)Don't pause between pages
-dBATCHN/A (not needed)Exit after processing
-dSAFERN/A (default)Safe file access
-sDEVICE=pdfwriteVarious PDF methodsOutput PDF
-sDEVICE=png16mToBitmap() or RasterizeToImageFiles()PNG output
-sOutputFile=XSaveAs("X")Output filename
-r300DPI parameter in methodsResolution
-dPDFSETTINGS=/ebookCompressImages(quality: 75)Medium quality
-sOwnerPassword=XSecuritySettings.OwnerPasswordOwner password
-sUserPassword=XSecuritySettings.UserPasswordUser password

Code Migration Examples

Example 1: HTML to PDF Conversion

Before (Ghostscript GPL):

// NuGet: Install-Package Ghostscript.NET
using Ghostscript.NET;
using Ghostscript.NET.Processor;
using System.IO;
using System.Text;

class GhostscriptExample
{
    static void Main()
    {
        // Ghostscript cannot directly convert HTML to PDF
        // You need to first convert HTML to PS/EPS using another tool
        // then use Ghostscript to convert PS to PDF

        string htmlContent = "<html><body><h1>Hello World</h1></body></html>";
        string psFile = "temp.ps";
        string outputPdf = "output.pdf";

        // This is a workaround - Ghostscript primarily works with PostScript
        GhostscriptProcessor processor = new GhostscriptProcessor();

        List<string> switches = new List<string>
        {
            "-dNOPAUSE",
            "-dBATCH",
            "-dSAFER",
            "-sDEVICE=pdfwrite",
            $"-sOutputFile={outputPdf}",
            psFile
        };

        processor.Process(switches.ToArray());
    }
}
// NuGet: Install-Package Ghostscript.NET
using Ghostscript.NET;
using Ghostscript.NET.Processor;
using System.IO;
using System.Text;

class GhostscriptExample
{
    static void Main()
    {
        // Ghostscript cannot directly convert HTML to PDF
        // You need to first convert HTML to PS/EPS using another tool
        // then use Ghostscript to convert PS to PDF

        string htmlContent = "<html><body><h1>Hello World</h1></body></html>";
        string psFile = "temp.ps";
        string outputPdf = "output.pdf";

        // This is a workaround - Ghostscript primarily works with PostScript
        GhostscriptProcessor processor = new GhostscriptProcessor();

        List<string> switches = new List<string>
        {
            "-dNOPAUSE",
            "-dBATCH",
            "-dSAFER",
            "-sDEVICE=pdfwrite",
            $"-sOutputFile={outputPdf}",
            psFile
        };

        processor.Process(switches.ToArray());
    }
}
$vbLabelText   $csharpLabel

After (IronPDF):

// NuGet: Install-Package IronPdf
using IronPdf;

class IronPdfExample
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();

        string htmlContent = "<html><body><h1>Hello World</h1></body></html>";

        var pdf = renderer.RenderHtmlAsPdf(htmlContent);
        pdf.SaveAs("output.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;

class IronPdfExample
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();

        string htmlContent = "<html><body><h1>Hello World</h1></body></html>";

        var pdf = renderer.RenderHtmlAsPdf(htmlContent);
        pdf.SaveAs("output.pdf");
    }
}
$vbLabelText   $csharpLabel

The difference is stark: Ghostscript GPL cannot directly convert HTML to PDF at all—it requires an intermediate PostScript conversion using external tools. IronPDF's ChromePdfRenderer provides direct HTML-to-PDF conversion with full CSS3, JavaScript, and modern web standards support. See the HTML to PDF documentation for more rendering options.

Example 2: PDF to Images

Before (Ghostscript GPL):

// NuGet: Install-Package Ghostscript.NET
using Ghostscript.NET;
using Ghostscript.NET.Rasterizer;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;

class GhostscriptExample
{
    static void Main()
    {
        string inputPdf = "input.pdf";
        string outputPath = "output";

        GhostscriptVersionInfo gvi = new GhostscriptVersionInfo("gsdll64.dll");

        using (GhostscriptRasterizer rasterizer = new GhostscriptRasterizer())
        {
            rasterizer.Open(inputPdf, gvi, false);

            for (int pageNumber = 1; pageNumber <= rasterizer.PageCount; pageNumber++)
            {
                Image img = rasterizer.GetPage(300, pageNumber);
                img.Save($"{outputPath}_page{pageNumber}.png", ImageFormat.Png);
                img.Dispose();
            }
        }
    }
}
// NuGet: Install-Package Ghostscript.NET
using Ghostscript.NET;
using Ghostscript.NET.Rasterizer;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;

class GhostscriptExample
{
    static void Main()
    {
        string inputPdf = "input.pdf";
        string outputPath = "output";

        GhostscriptVersionInfo gvi = new GhostscriptVersionInfo("gsdll64.dll");

        using (GhostscriptRasterizer rasterizer = new GhostscriptRasterizer())
        {
            rasterizer.Open(inputPdf, gvi, false);

            for (int pageNumber = 1; pageNumber <= rasterizer.PageCount; pageNumber++)
            {
                Image img = rasterizer.GetPage(300, pageNumber);
                img.Save($"{outputPath}_page{pageNumber}.png", ImageFormat.Png);
                img.Dispose();
            }
        }
    }
}
$vbLabelText   $csharpLabel

After (IronPDF):

// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class IronPdfExample
{
    static void Main()
    {
        var pdf = PdfDocument.FromFile("input.pdf");

        var images = pdf.ToBitmap();

        for (int i = 0; i < images.Length; i++)
        {
            images[i].Save($"output_page{i + 1}.png");
        }
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class IronPdfExample
{
    static void Main()
    {
        var pdf = PdfDocument.FromFile("input.pdf");

        var images = pdf.ToBitmap();

        for (int i = 0; i < images.Length; i++)
        {
            images[i].Save($"output_page{i + 1}.png");
        }
    }
}
$vbLabelText   $csharpLabel

The Ghostscript GPL approach requires locating the external gsdll64.dll, creating a GhostscriptVersionInfo object, and using 1-indexed page numbers. IronPDF's ToBitmap() method provides a clean, single-line approach with no external dependencies. Note the page indexing difference: Ghostscript GPL uses 1-indexed pages while IronPDF uses 0-indexed (standard .NET convention).

Example 3: Merge PDF Files

Before (Ghostscript GPL):

// NuGet: Install-Package Ghostscript.NET
using Ghostscript.NET;
using Ghostscript.NET.Processor;
using System.Collections.Generic;

class GhostscriptExample
{
    static void Main()
    {
        string outputPdf = "merged.pdf";
        string[] inputFiles = { "file1.pdf", "file2.pdf", "file3.pdf" };

        GhostscriptProcessor processor = new GhostscriptProcessor();

        List<string> switches = new List<string>
        {
            "-dNOPAUSE",
            "-dBATCH",
            "-dSAFER",
            "-sDEVICE=pdfwrite",
            $"-sOutputFile={outputPdf}"
        };

        switches.AddRange(inputFiles);

        processor.Process(switches.ToArray());
    }
}
// NuGet: Install-Package Ghostscript.NET
using Ghostscript.NET;
using Ghostscript.NET.Processor;
using System.Collections.Generic;

class GhostscriptExample
{
    static void Main()
    {
        string outputPdf = "merged.pdf";
        string[] inputFiles = { "file1.pdf", "file2.pdf", "file3.pdf" };

        GhostscriptProcessor processor = new GhostscriptProcessor();

        List<string> switches = new List<string>
        {
            "-dNOPAUSE",
            "-dBATCH",
            "-dSAFER",
            "-sDEVICE=pdfwrite",
            $"-sOutputFile={outputPdf}"
        };

        switches.AddRange(inputFiles);

        processor.Process(switches.ToArray());
    }
}
$vbLabelText   $csharpLabel

After (IronPDF):

// NuGet: Install-Package IronPdf
using IronPdf;
using System.Collections.Generic;

class IronPdfExample
{
    static void Main()
    {
        var pdfs = new List<PdfDocument>
        {
            PdfDocument.FromFile("file1.pdf"),
            PdfDocument.FromFile("file2.pdf"),
            PdfDocument.FromFile("file3.pdf")
        };

        var merged = PdfDocument.Merge(pdfs);
        merged.SaveAs("merged.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System.Collections.Generic;

class IronPdfExample
{
    static void Main()
    {
        var pdfs = new List<PdfDocument>
        {
            PdfDocument.FromFile("file1.pdf"),
            PdfDocument.FromFile("file2.pdf"),
            PdfDocument.FromFile("file3.pdf")
        };

        var merged = PdfDocument.Merge(pdfs);
        merged.SaveAs("merged.pdf");
    }
}
$vbLabelText   $csharpLabel

The Ghostscript GPL approach requires memorizing switch syntax (-dNOPAUSE, -dBATCH, -sDEVICE=pdfwrite) and concatenating file paths into a string array. IronPDF's static Merge method provides type-safe, IntelliSense-enabled merging with proper PdfDocument objects. Learn more about merging and splitting PDFs.


Critical Migration Notes

Page Indexing Conversion

One of the most important changes in this Ghostscript GPL migration is the page indexing difference:

// Ghostscript GPL: 1-indexed pages
for (int pageNumber = 1; pageNumber <= rasterizer.PageCount; pageNumber++)
{
    Image img = rasterizer.GetPage(300, pageNumber);
}

// IronPDF: 0-indexed pages (standard .NET)
for (int i = 0; i < images.Length; i++)
{
    images[i].Save($"output_page{i + 1}.png");
}
// Ghostscript GPL: 1-indexed pages
for (int pageNumber = 1; pageNumber <= rasterizer.PageCount; pageNumber++)
{
    Image img = rasterizer.GetPage(300, pageNumber);
}

// IronPDF: 0-indexed pages (standard .NET)
for (int i = 0; i < images.Length; i++)
{
    images[i].Save($"output_page{i + 1}.png");
}
$vbLabelText   $csharpLabel

AGPL License Concerns Eliminated

Ghostscript GPL's AGPL license has "viral" properties that require source code disclosure when distributing applications. IronPDF's commercial license has clear terms with no such requirements.

No External Binaries

IronPDF is entirely self-contained. Remove these after migration:

  • gsdll32.dll and gsdll64.dll files
  • Ghostscript GPL installation from servers
  • PATH environment variable configurations
  • GhostscriptVersionInfo references in code

PostScript Files

IronPDF doesn't handle PostScript (.ps) files directly. If your workflow requires PostScript processing, either:

  1. Convert PostScript to PDF using another tool before IronPDF processing
  2. Convert source content to HTML and use IronPDF's HTML rendering

Performance Considerations

No Process Spawning

Ghostscript GPL operations spawn external processes with associated overhead. IronPDF operates within your .NET process:

// Ghostscript GPL: Process spawning overhead
processor.Process(switches.ToArray());  // Creates new OS process

// IronPDF: In-process execution
var merged = PdfDocument.Merge(pdfs);  // Native .NET method call
// Ghostscript GPL: Process spawning overhead
processor.Process(switches.ToArray());  // Creates new OS process

// IronPDF: In-process execution
var merged = PdfDocument.Merge(pdfs);  // Native .NET method call
$vbLabelText   $csharpLabel

Thread Safety

IronPDF is thread-safe by design. Multiple threads can use ChromePdfRenderer and PdfDocument simultaneously without synchronization concerns.


Migration Checklist

Pre-Migration

  • Inventory all Ghostscript GPL usage in codebase
  • Document current command-line switches used
  • Identify any PostScript processing (needs special handling)
  • Review AGPL license compliance status
  • Obtain IronPDF license key
  • Create migration branch in version control

Code Migration

  • Remove Ghostscript.NET NuGet package: dotnet remove package Ghostscript.NET
  • Install IronPdf NuGet package: dotnet add package IronPdf
  • Remove external Ghostscript GPL binary dependencies
  • Remove GhostscriptVersionInfo and DLL references
  • Convert GhostscriptProcessor.Process() to IronPDF methods
  • Convert GhostscriptRasterizer to pdf.ToBitmap()
  • Replace command-line switches with API calls
  • Update error handling from stderr parsing to exceptions
  • Convert 1-indexed page numbers to 0-indexed

Testing

  • Test PDF to image conversion
  • Test PDF merging
  • Test page extraction
  • Test compression quality
  • Test password protection
  • Verify output quality matches expectations
  • Performance benchmark critical paths

Deployment

  • Remove Ghostscript GPL from servers
  • Remove PATH configuration
  • Remove gsdll*.dll files from deployments
  • Verify application works without Ghostscript GPL installed

Post-Migration

  • Remove Ghostscript GPL license (if commercial)
  • Update documentation
  • Train team on IronPDF API
  • Monitor production for any issues

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