IRONSOFTWAREHOME
MIGRATION GUIDES

How to Migrate from Ghostscript GPL to IronPDF in C#

Curtis Chau
Curtis Chau
Updated: August 1, 2026

Migrating from Ghostscript to IronPDF moves your .NET PDF workflow off command-line process spawning and string-based switch manipulation onto a typed, IntelliSense-enabled native .NET API. This guide walks through a step-by-step migration path that removes AGPL-3.0 licensing exposure and the external native binary dependency.

A note on terminology: Ghostscript (by Artifex Software) is dual-licensed under AGPL-3.0 or a commercial license, not plain GPL. The "GPL" tag is a long-standing community shorthand for the open-source build; everything in this guide refers to the AGPL-3.0 build of Ghostscript and the Ghostscript.NET wrapper (which is also AGPL-3.0 / commercial-dual). From .NET, Ghostscript is typically consumed via that wrapper, which P/Invokes the native gsdll32.dll / gsdll64.dll, or by shelling out to gswin32c / gswin64c via Process.Start.

Why Migrate from Ghostscript to IronPDF

The Ghostscript Challenges

Ghostscript is a long-standing PostScript/PDF interpreter from Artifex Software with decades of history. Its use in modern .NET applications presents several practical challenges:

  1. AGPL-3.0 License Restrictions: Both Ghostscript itself and the Ghostscript.NET wrapper are dual-licensed under AGPL-3.0 or a commercial license from Artifex. AGPL's network-copyleft clause typically requires that you release the corresponding source of the larger work - including for SaaS / network use - unless you purchase a commercial license. This often rules out the AGPL build for closed-source or hosted .NET applications.
  2. Command-Line Interface: Ghostscript is fundamentally a command-line tool. Using it from C# means spawning processes, passing string arguments, and parsing output - either via Process.Start against gswin*c.exe or via the Ghostscript.NET P/Invoke wrapper.
  3. External Binary Dependency: You must install Ghostscript separately, manage PATH variables, and keep versions aligned across environments. Different native DLLs are required for 32-bit vs 64-bit (gsdll32.dll vs gsdll64.dll).
  4. No Native HTML-to-PDF: Ghostscript cannot convert HTML to PDF directly. You first need to convert HTML to PostScript with another tool, then run Ghostscript to convert PostScript to PDF - a multi-step pipeline with external dependencies.
  5. Complex Switch Syntax: Operations are controlled via command-line switches like -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=.... No IntelliSense, no compile-time checks.
  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 timeouts and resource cleanup.

Ghostscript vs IronPDF Comparison

AspectGhostscriptIronPDF
LicenseAGPL-3.0 (network-copyleft) or Artifex 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 .NETGhostscript.NET v1.3.x targets .NET Standard 2.0.NET Framework 4.6.2+ and .NET 6/7/8/9
Async SupportProcess-basedNative async/await

Migration Complexity Assessment

Estimated Effort by Feature

FeatureMigration Complexity
PDF to ImagesLow
Merge PDFsLow
Compress PDFLow
PDF OptimizationLow
EncryptionMedium
Page ExtractionLow
PostScript to PDFMedium-High
Custom SwitchesMedium-High

Paradigm Shift

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

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

Before You Start

Prerequisites

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

Identify All Ghostscript 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" .
SHELL

NuGet Package Changes

# Remove Ghostscript.NET
dotnet remove package Ghostscript.NET

# Install IronPDF
dotnet add package IronPdf
SHELL

Remove Ghostscript Dependencies

After migration:

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

Quick Start Migration

Step 1: Update License Configuration

Before (Ghostscript):

Ghostscript under AGPL-3.0 requires either source disclosure under AGPL terms or a commercial license from Artifex.

After (IronPDF):

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

Step 2: Update Namespace Imports

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

// After (IronPDF)
using IronPdf;

Complete API Reference

Core Class Mapping

Ghostscript.NETIronPDFDescription
GhostscriptProcessorVarious PdfDocument methodsPDF processing
GhostscriptRasterizerPdfDocument.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 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=png16mRasterizeToImageFiles("*.png", DPI: N)PNG output
-sOutputFile=XSaveAs("X")Output filename
-r300DPI: 300 parameterResolution
-dPDFSETTINGS=/ebookCompressImages(quality: 60)Medium quality
-dFirstPage=N -dLastPage=MCopyPages(new[] {N-1, ..., M-1})Page extraction (0-indexed)
-sOwnerPassword=XSecuritySettings.OwnerPasswordOwner password
-sUserPassword=XSecuritySettings.UserPasswordUser password

Code Migration Examples

Example 1: HTML to PDF Conversion

Before (Ghostscript):

// 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());
    }
}

After (IronPDF):

// NuGet: Install-Package IronPdf
using IronPdf;

class IronPdfExample
{
    static void Main()
    {
        IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";

        var renderer = new ChromePdfRenderer();

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

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

Ghostscript cannot directly convert HTML to PDF - it expects PostScript or PDF input, so an HTML workflow requires an intermediate conversion (typically via wkhtmltopdf or similar). IronPDF's ChromePdfRenderer provides direct HTML-to-PDF rendering with CSS, JavaScript, and modern web standards support via an embedded Chromium engine. See the HTML to PDF documentation for more rendering options.

Example 2: PDF to Images

Before (Ghostscript):

// 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();
            }
        }
    }
}

After (IronPDF):

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

class IronPdfExample
{
    static void Main()
    {
        IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";

        var pdf = PdfDocument.FromFile("input.pdf");

        // One-shot: write every page as PNG matching Ghostscript's -r300 -sDEVICE=png16m
        pdf.RasterizeToImageFiles("output_page*.png", DPI: 300);
    }
}

The Ghostscript approach requires locating the external gsdll64.dll, creating a GhostscriptVersionInfo object, and iterating pages with 1-indexed page numbers. IronPDF's RasterizeToImageFiles writes every page in a single call with a glob output pattern and an explicit DPI: parameter, with no external native dependency. Note that when you do work with page indices, Ghostscript uses 1-indexed pages while IronPDF uses 0-indexed pages (standard .NET convention).

Example 3: Merge PDF Files

Before (Ghostscript):

// 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());
    }
}

After (IronPDF):

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

class IronPdfExample
{
    static void Main()
    {
        IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";

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

The Ghostscript approach requires the full switch incantation (-dNOPAUSE, -dBATCH, -sDEVICE=pdfwrite) and concatenating file paths into a string array. IronPDF's static Merge method takes a typed IEnumerable<PdfDocument> and returns a new PdfDocument. Learn more about merging and splitting PDFs.


Critical Migration Notes

Page Indexing Conversion

One of the most important differences in this migration is page indexing. Ghostscript switches like -dFirstPage=N / -dLastPage=M are 1-indexed; IronPDF's CopyPages is 0-indexed (standard .NET):

// Ghostscript: -dFirstPage=5 -dLastPage=8 (1-indexed, inclusive)

// IronPDF: 0-indexed page array
var extracted = pdf.CopyPages(new[] {4, 5, 6, 7});
extracted.SaveAs("pages_5_to_8.pdf");

AGPL-3.0 License Concerns

Both Ghostscript and the Ghostscript.NET wrapper are dual-licensed under AGPL-3.0 or a commercial license from Artifex. AGPL-3.0's network-copyleft clause typically requires releasing the corresponding source of the larger work - including for SaaS / network-accessible deployments - unless you hold an Artifex commercial license. Migrating PDF workloads to IronPDF removes that obligation for the parts that move; if you keep Ghostscript only for PostScript ingest, an Artifex commercial license covers that piece. (This is a general summary, not legal advice - consult counsel for your specific deployment.)

No External Binaries

IronPDF is distributed as a NuGet package. Remove these after migration:

  • gsdll32.dll and gsdll64.dll files
  • Ghostscript 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

Shelling out to gswin64c.exe (or P/Invoking gsdll64.dll) carries process and native-interop overhead per operation. IronPDF runs in-process as managed .NET code:

// Ghostscript: process or P/Invoke overhead per call
processor.Process(switches.ToArray());

// IronPDF: in-process method call
var merged = PdfDocument.Merge(pdfs);

Thread Safety

IronPDF supports concurrent use of ChromePdfRenderer and PdfDocument from multiple threads. See the IronPDF documentation for guidance on parallel rendering patterns.


Migration Checklist

Pre-Migration

  • Inventory all Ghostscript usage in codebase
  • Document current command-line switches used
  • Identify any PostScript processing (needs special handling)
  • Review AGPL-3.0 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 binary dependencies
  • Remove GhostscriptVersionInfo and DLL references
  • Convert GhostscriptProcessor.Process() to IronPDF methods
  • Convert GhostscriptRasterizer to pdf.RasterizeToImageFiles()
  • 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 from servers
  • Remove PATH configuration
  • Remove gsdll*.dll files from deployments
  • Verify application works without Ghostscript installed

Post-Migration

  • Cancel Artifex commercial license (if previously held and no longer needed)
  • Update documentation
  • Train team on IronPDF API
  • Monitor production for any issues

Please note: Ghostscript is a registered trademark of its respective owner. This site is not affiliated with, endorsed by, or sponsored by Artifex Software. 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