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:
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.
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.
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.dllvsgsdll64.dll).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.
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.Error Handling: Errors come through stderr as text strings, requiring parsing rather than structured exception handling.
- 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 | Notes |
|---|---|---|
| PDF to Images | Low | Direct API mapping |
| Merge PDFs | Low | Simpler with IronPDF |
| Compress PDF | Low | Built-in options |
| PDF Optimization | Low | Different approach |
| Encryption | Medium | Different API |
| Page Extraction | Low | 0-indexed vs 1-indexed |
| PostScript to PDF | Medium-High | Convert PS → PDF first |
| Custom Switches | Medium-High | Research 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
- .NET Version: IronPDF supports .NET Framework 4.6.2+ and .NET Core 2.0+ / .NET 5/6/7/8/9+
- License Key: Obtain your IronPDF license key from ironpdf.com
- 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" .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 IronPdfRemove Ghostscript GPL Dependencies
After migration:
- Uninstall Ghostscript GPL from servers
- Remove
gsdll32.dll/gsdll64.dllfrom deployments - Remove PATH configuration for Ghostscript GPL
- Remove any
GhostscriptVersionInforeferences
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";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;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());
}
}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");
}
}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();
}
}
}
}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");
}
}
}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());
}
}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");
}
}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");
}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.dllandgsdll64.dllfiles- Ghostscript GPL installation from servers
- PATH environment variable configurations
GhostscriptVersionInforeferences in code
PostScript Files
IronPDF doesn't handle PostScript (.ps) files directly. If your workflow requires PostScript processing, either:
- Convert PostScript to PDF using another tool before IronPDF processing
- 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 callThread 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
GhostscriptVersionInfoand DLL references - Convert
GhostscriptProcessor.Process()to IronPDF methods - Convert
GhostscriptRasterizertopdf.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*.dllfiles 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






