푸터 콘텐츠로 바로가기
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

Aspect Ghostscript GPL IronPDF
License AGPL (viral) or expensive commercial Commercial with clear terms
Integration Command-line process spawning Native .NET library
API Design String-based switches Typed, IntelliSense-enabled API
Error Handling Parse stderr text .NET exceptions
HTML-to-PDF Not supported (need external tools) Built-in Chromium engine
Dependencies External binary installation Self-contained NuGet package
Deployment Configure PATH, copy DLLs Just add NuGet reference
Thread Safety Process isolation only Thread-safe by design
Modern .NET Limited support Full .NET 6/7/8/9/10 support
Async Support Process-based Native 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

Feature Migration Complexity
PDF to Images Low
Merge PDFs Low
Compress PDF Low
PDF Optimization Low
Encryption Medium
Page Extraction Low
PostScript to PDF Medium-High
Custom Switches Medium-High

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.NET IronPDF Description
GhostscriptProcessor Various PdfDocument methods PDF processing
GhostscriptRasterizer PdfDocument.ToBitmap() / RasterizeToImageFiles() PDF to images
GhostscriptVersionInfo N/A (not needed) DLL location
GhostscriptStdIO N/A (use exceptions) I/O handling
Process + command-line ChromePdfRenderer HTML to PDF

Command-Line Switch Mapping

Ghostscript GPL Switch IronPDF Equivalent Description
-dNOPAUSE N/A (not needed) Don't pause between pages
-dBATCH N/A (not needed) Exit after processing
-dSAFER N/A (default) Safe file access
-sDEVICE=pdfwrite Various PDF methods Output PDF
-sDEVICE=png16m ToBitmap() or RasterizeToImageFiles() PNG output
-sOutputFile=X SaveAs("X") Output filename
-r300 DPI parameter in methods Resolution
-dPDFSETTINGS=/ebook CompressImages(quality: 75) Medium quality
-sOwnerPassword=X SecuritySettings.OwnerPassword Owner password
-sUserPassword=X SecuritySettings.UserPassword User 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

커티스 차우
기술 문서 작성자

커티스 차우는 칼턴 대학교에서 컴퓨터 과학 학사 학위를 취득했으며, Node.js, TypeScript, JavaScript, React를 전문으로 하는 프론트엔드 개발자입니다. 직관적이고 미적으로 뛰어난 사용자 인터페이스를 만드는 데 열정을 가진 그는 최신 프레임워크를 활용하고, 잘 구성되고 시각적으로 매력적인 매뉴얼을 제작하는 것을 즐깁니다.

커티스는 개발 분야 외에도 사물 인터넷(IoT)에 깊은 관심을 가지고 있으며, 하드웨어와 소프트웨어를 통합하는 혁신적인 방법을 연구합니다. 여가 시간에는 게임을 즐기거나 디스코드 봇을 만들면서 기술에 대한 애정과 창의성을 결합합니다.