How to Migrate from RawPrint to IronPDF in C#
Moving from RawPrint to IronPDF is less a replacement than a refit: RawPrint and IronPDF solve different problems, and the honest framing for most teams is "complement," not "replace." This guide walks the cases where IronPDF genuinely subsumes a RawPrint pipeline (create-a-PDF-then-push-it workflows on Windows) and flags the cases where you should keep RawPrint in place (ESC/POS, ZPL, EPL, raw PCL).
Why Migrate from RawPrint to IronPDF
Understanding RawPrint
RawPrint is the NuGet package RawPrint (frogmorecs/RawPrint, v0.5.0, last released September 2019, now unlisted/legacy on nuget.org). It is a thin P/Invoke wrapper over winspool.Drv that ships a byte stream straight to the Windows print spooler with the RAW datatype. The public API is small: a Printer class implementing IPrinter in the RawPrint namespace, exposing PrintRawFile and PrintRawStream overloads. The underlying Win32 calls (OpenPrinter, StartDocPrinter, WritePrinter, EndDocPrinter, ClosePrinter) are hidden behind that interface — you do not write them yourself when using the package.
That makes RawPrint a good fit for ESC/POS receipt printers, ZPL/EPL Zebra label printers, and legacy PCL/PostScript jobs where you have already produced the bytes the printer firmware expects. For developers targeting Windows-specific environments and requiring direct printer communication, RawPrint offers an efficient pathway bypassing intermediary layers like drivers or graphical interfaces.
However, RawPrint is not a PDF library — it just pushes data to printers. If your application currently builds a PDF in some other library and then hands it to RawPrint, that whole pipeline can usually collapse into IronPDF on Windows.
The Core Problem: No PDF Creation
RawPrint has notable limitations that make it unsuitable for modern document workflows:
-
No PDF Creation: RawPrint focuses solely on data transmission, lacking functionality for PDF creation, rendering, or manipulation.
-
Very Low-Level: By dealing directly with raw bytes, developers must have a deep understanding of the printer's command language, making it less suitable for straightforward document printing tasks.
-
Platform-Specific: It depends on Windows print spoolers, limiting its cross-platform applicability.
-
No Document Processing: Just byte transmission with no rendering capabilities.
- Limited Control: Minimal print job configuration options.
RawPrint vs IronPDF Comparison
| Feature | RawPrint | IronPDF |
|---|---|---|
| Functionality | Sends raw print data directly to the printer | Comprehensive PDF creation and manipulation |
| Use Case | Specialized printing like labels | General document management and creation |
| Platform Dependency | Windows-specific | Cross-platform |
| Complexity | Low-level, requires printer command knowledge | High-level, user-friendly API |
| PDF Creation | No | Yes |
| Create PDF from HTML | No | Yes |
| Create PDF from URL | No | Yes |
| Edit/Modify PDFs | No | Yes |
| Merge/Split PDFs | No | Yes |
| Print Existing PDF | Yes (raw bytes) | Yes (high-level API) |
| Print Control | Basic | Full options |
| Ideal For | Direct printer access needs | PDF-related tasks in web and desktop apps |
| Flexibility | Limited due to raw byte handling | Extensive with multiple functionalities |
In stark contrast to RawPrint, IronPDF offers a robust and versatile API for handling PDFs comprehensively. As an established name in the .NET environment, IronPDF enables developers to create, edit, and convert PDFs effortlessly across platforms.
For teams targeting modern .NET, IronPDF provides cross-platform compatibility that RawPrint, by design, does not.
Before You Start
Prerequisites
- .NET Environment: .NET Framework 4.6.2+ or .NET Core 3.1+ / .NET 5/6/7/8/9+
- NuGet Access: Ability to install NuGet packages
- IronPDF License: Obtain your license key from ironpdf.com
NuGet Package Changes
# Remove RawPrint
dotnet remove package RawPrint
# Install IronPDF
dotnet add package IronPdf
# Remove RawPrint
dotnet remove package RawPrint
# Install IronPDF
dotnet add package IronPdf
License Configuration
// Add at application startup
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
// Add at application startup
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
' Add at application startup
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
Find RawPrint Usage
# Identify all RawPrint usage
grep -r "using RawPrint" --include="*.cs" .
grep -r "PrintRawFile\|PrintRawStream" --include="*.cs" .
# Identify all RawPrint usage
grep -r "using RawPrint" --include="*.cs" .
grep -r "PrintRawFile\|PrintRawStream" --include="*.cs" .
Note: hand-rolled P/Invoke wrappers around winspool.Drv sometimes use the class name RawPrinterHelper and look superficially similar to RawPrint usage, but they are not the package — they call the Win32 spooler directly. The package itself only exposes IPrinter with PrintRawFile and PrintRawStream.
Complete API Reference
Namespace Changes
// Before: RawPrint
using RawPrint;
// After: IronPDF
using IronPdf;
// Before: RawPrint
using RawPrint;
// After: IronPDF
using IronPdf;
Imports IronPdf
Core API Mappings
| RawPrint (real public API) | IronPDF | Notes |
|---|---|---|
new Printer() / IPrinter |
new ChromePdfRenderer() / PdfDocument |
RawPrint pushes bytes; IronPDF generates PDFs |
printer.PrintRawFile(name, path, paused) |
PdfDocument.FromFile(path).Print() |
IronPDF re-renders to the OS print system; not RAW |
printer.PrintRawStream(name, stream, doc, paused) |
new PdfDocument(stream).Print() |
Same caveat |
printer.OnJobCreated event |
n/a | Use IronPDF print options instead |
| n/a | ChromePdfRenderer.RenderHtmlAsPdf() |
Create PDFs |
| n/a | PdfDocument.Merge() |
Merge PDFs |
| n/a | pdf.ApplyWatermark() |
Add watermarks |
IronPDF prints by handing the document to the operating system, not by streaming raw bytes to the spooler. If your printer requires the RAW datatype (ESC/POS, ZPL, certain PCL workflows), that is RawPrint's lane and IronPDF cannot stand in for it.
Code Migration Examples
Example 1: HTML to PDF Conversion
Before (RawPrint):
// NuGet: Install-Package RawPrint
using System;
using System.IO;
using System.Text;
using RawPrint;
class Program
{
static void Main()
{
// RawPrint cannot convert HTML to PDF. Sending raw HTML bytes to a printer just
// prints the HTML source as text — the markup is not rendered.
string html = "<html><body><h1>Hello World</h1></body></html>";
byte[] data = Encoding.ASCII.GetBytes(html);
IPrinter printer = new Printer();
using (var stream = new MemoryStream(data))
{
// PrintRawStream(printerName, stream, documentName, paused)
printer.PrintRawStream("Microsoft Print to PDF", stream, "HTML Document", false);
}
Console.WriteLine("Raw HTML bytes sent to spooler (not rendered).");
}
}
// NuGet: Install-Package RawPrint
using System;
using System.IO;
using System.Text;
using RawPrint;
class Program
{
static void Main()
{
// RawPrint cannot convert HTML to PDF. Sending raw HTML bytes to a printer just
// prints the HTML source as text — the markup is not rendered.
string html = "<html><body><h1>Hello World</h1></body></html>";
byte[] data = Encoding.ASCII.GetBytes(html);
IPrinter printer = new Printer();
using (var stream = new MemoryStream(data))
{
// PrintRawStream(printerName, stream, documentName, paused)
printer.PrintRawStream("Microsoft Print to PDF", stream, "HTML Document", false);
}
Console.WriteLine("Raw HTML bytes sent to spooler (not rendered).");
}
}
Imports System
Imports System.IO
Imports System.Text
Imports RawPrint
Class Program
Shared Sub Main()
' RawPrint cannot convert HTML to PDF. Sending raw HTML bytes to a printer just
' prints the HTML source as text — the markup is not rendered.
Dim html As String = "<html><body><h1>Hello World</h1></body></html>"
Dim data As Byte() = Encoding.ASCII.GetBytes(html)
Dim printer As IPrinter = New Printer()
Using stream As New MemoryStream(data)
' PrintRawStream(printerName, stream, documentName, paused)
printer.PrintRawStream("Microsoft Print to PDF", stream, "HTML Document", False)
End Using
Console.WriteLine("Raw HTML bytes sent to spooler (not rendered).")
End Sub
End Class
After (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
var renderer = new ChromePdfRenderer();
string html = "<html><body><h1>Hello World</h1></body></html>";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("output.pdf");
Console.WriteLine("PDF created successfully");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
var renderer = new ChromePdfRenderer();
string html = "<html><body><h1>Hello World</h1></body></html>";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("output.pdf");
Console.WriteLine("PDF created successfully");
}
}
Imports IronPdf
Imports System
Class Program
Shared Sub Main()
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
Dim renderer = New ChromePdfRenderer()
Dim html As String = "<html><body><h1>Hello World</h1></body></html>"
Dim pdf = renderer.RenderHtmlAsPdf(html)
pdf.SaveAs("output.pdf")
Console.WriteLine("PDF created successfully")
End Sub
End Class
The architectural mismatch is visible even with the package's own friendly API: RawPrint ships bytes to a Windows spooler with the RAW datatype, so handing it HTML just causes the printer to print the source text. IronPDF's ChromePdfRenderer actually renders the markup. See the HTML to PDF documentation for comprehensive examples.
Example 2: URL to PDF Conversion
Before (RawPrint):
// NuGet: Install-Package RawPrint
using System;
using System.IO;
using System.Net.Http;
using System.Text;
using RawPrint;
class Program
{
static void Main()
{
// RawPrint cannot fetch a URL or render a web page; downloading the HTML and
// shipping it to the spooler just prints the raw HTML source.
using (var client = new HttpClient())
{
string htmlSource = client.GetStringAsync("https://example.com").GetAwaiter().GetResult();
byte[] data = Encoding.UTF8.GetBytes(htmlSource);
IPrinter printer = new Printer();
using (var stream = new MemoryStream(data))
{
printer.PrintRawStream("Microsoft Print to PDF", stream, "Web Page", false);
}
Console.WriteLine("Raw HTML sent to spooler (not a rendered PDF).");
}
}
}
// NuGet: Install-Package RawPrint
using System;
using System.IO;
using System.Net.Http;
using System.Text;
using RawPrint;
class Program
{
static void Main()
{
// RawPrint cannot fetch a URL or render a web page; downloading the HTML and
// shipping it to the spooler just prints the raw HTML source.
using (var client = new HttpClient())
{
string htmlSource = client.GetStringAsync("https://example.com").GetAwaiter().GetResult();
byte[] data = Encoding.UTF8.GetBytes(htmlSource);
IPrinter printer = new Printer();
using (var stream = new MemoryStream(data))
{
printer.PrintRawStream("Microsoft Print to PDF", stream, "Web Page", false);
}
Console.WriteLine("Raw HTML sent to spooler (not a rendered PDF).");
}
}
}
Imports System
Imports System.IO
Imports System.Net.Http
Imports System.Text
Imports RawPrint
Module Program
Sub Main()
' RawPrint cannot fetch a URL or render a web page; downloading the HTML and
' shipping it to the spooler just prints the raw HTML source.
Using client As New HttpClient()
Dim htmlSource As String = client.GetStringAsync("https://example.com").GetAwaiter().GetResult()
Dim data As Byte() = Encoding.UTF8.GetBytes(htmlSource)
Dim printer As IPrinter = New Printer()
Using stream As New MemoryStream(data)
printer.PrintRawStream("Microsoft Print to PDF", stream, "Web Page", False)
End Using
Console.WriteLine("Raw HTML sent to spooler (not a rendered PDF).")
End Using
End Sub
End Module
After (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
var renderer = new ChromePdfRenderer();
// Render a live website directly to PDF with full CSS, JavaScript, and images
var pdf = renderer.RenderUrlAsPdf("https://example.com");
pdf.SaveAs("webpage.pdf");
Console.WriteLine("Website rendered to PDF successfully");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
var renderer = new ChromePdfRenderer();
// Render a live website directly to PDF with full CSS, JavaScript, and images
var pdf = renderer.RenderUrlAsPdf("https://example.com");
pdf.SaveAs("webpage.pdf");
Console.WriteLine("Website rendered to PDF successfully");
}
}
Imports IronPdf
Imports System
Class Program
Shared Sub Main()
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
Dim renderer = New ChromePdfRenderer()
' Render a live website directly to PDF with full CSS, JavaScript, and images
Dim pdf = renderer.RenderUrlAsPdf("https://example.com")
pdf.SaveAs("webpage.pdf")
Console.WriteLine("Website rendered to PDF successfully")
End Sub
End Class
RawPrint cannot render web pages — it only ships bytes to the spooler. Downloading HTML and pushing it through results in the printer printing the source text, not rendered content. IronPDF's RenderUrlAsPdf() captures the fully rendered webpage with CSS, JavaScript, and images. Learn more in our tutorials.
Example 3: Document Formatting
Before (RawPrint):
// NuGet: Install-Package RawPrint
using System;
using System.IO;
using System.Text;
using RawPrint;
class Program
{
static void Main()
{
// RawPrint has no concept of fonts, margins, or layout — formatting must be
// expressed in the printer's own command language (PCL, PostScript, ESC/POS, ZPL).
// Example: a tiny PCL5 stream that selects portrait and a 16.66cpi font.
string pclCommands = "\x1B&l0O\x1B(s0p16.66h8.5v0s0b3T";
string text = "Plain text document - formatting must be expressed in printer command language";
byte[] data = Encoding.ASCII.GetBytes(pclCommands + text);
IPrinter printer = new Printer();
using (var stream = new MemoryStream(data))
{
printer.PrintRawStream("HP LaserJet", stream, "Raw Document", false);
}
}
}
// NuGet: Install-Package RawPrint
using System;
using System.IO;
using System.Text;
using RawPrint;
class Program
{
static void Main()
{
// RawPrint has no concept of fonts, margins, or layout — formatting must be
// expressed in the printer's own command language (PCL, PostScript, ESC/POS, ZPL).
// Example: a tiny PCL5 stream that selects portrait and a 16.66cpi font.
string pclCommands = "\x1B&l0O\x1B(s0p16.66h8.5v0s0b3T";
string text = "Plain text document - formatting must be expressed in printer command language";
byte[] data = Encoding.ASCII.GetBytes(pclCommands + text);
IPrinter printer = new Printer();
using (var stream = new MemoryStream(data))
{
printer.PrintRawStream("HP LaserJet", stream, "Raw Document", false);
}
}
}
Imports System
Imports System.IO
Imports System.Text
Imports RawPrint
Class Program
Shared Sub Main()
' RawPrint has no concept of fonts, margins, or layout — formatting must be
' expressed in the printer's own command language (PCL, PostScript, ESC/POS, ZPL).
' Example: a tiny PCL5 stream that selects portrait and a 16.66cpi font.
Dim pclCommands As String = ChrW(&H1B) & "&l0O" & ChrW(&H1B) & "(s0p16.66h8.5v0s0b3T"
Dim text As String = "Plain text document - formatting must be expressed in printer command language"
Dim data As Byte() = Encoding.ASCII.GetBytes(pclCommands & text)
Dim printer As IPrinter = New Printer()
Using stream As New MemoryStream(data)
printer.PrintRawStream("HP LaserJet", stream, "Raw Document", False)
End Using
End Sub
End Class
After (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
var renderer = new ChromePdfRenderer();
string html = @"
<html>
<head>
<style>
body { font-family: Arial; margin: 40px; }
h1 { color: #2c3e50; font-size: 24px; }
p { line-height: 1.6; color: #34495e; }
.highlight { background-color: yellow; font-weight: bold; }
</style>
</head>
<body>
<h1>Formatted Document</h1>
<p>This is a <span class='highlight'>beautifully formatted</span> document with CSS styling.</p>
<p>Complex layouts, fonts, colors, and images are fully supported.</p>
</body>
</html>";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("formatted.pdf");
Console.WriteLine("Formatted PDF created successfully");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
var renderer = new ChromePdfRenderer();
string html = @"
<html>
<head>
<style>
body { font-family: Arial; margin: 40px; }
h1 { color: #2c3e50; font-size: 24px; }
p { line-height: 1.6; color: #34495e; }
.highlight { background-color: yellow; font-weight: bold; }
</style>
</head>
<body>
<h1>Formatted Document</h1>
<p>This is a <span class='highlight'>beautifully formatted</span> document with CSS styling.</p>
<p>Complex layouts, fonts, colors, and images are fully supported.</p>
</body>
</html>";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("formatted.pdf");
Console.WriteLine("Formatted PDF created successfully");
}
}
Imports IronPdf
Imports System
Module Program
Sub Main()
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
Dim renderer As New ChromePdfRenderer()
Dim html As String = "
<html>
<head>
<style>
body { font-family: Arial; margin: 40px; }
h1 { color: #2c3e50; font-size: 24px; }
p { line-height: 1.6; color: #34495e; }
.highlight { background-color: yellow; font-weight: bold; }
</style>
</head>
<body>
<h1>Formatted Document</h1>
<p>This is a <span class='highlight'>beautifully formatted</span> document with CSS styling.</p>
<p>Complex layouts, fonts, colors, and images are fully supported.</p>
</body>
</html>"
Dim pdf = renderer.RenderHtmlAsPdf(html)
pdf.SaveAs("formatted.pdf")
Console.WriteLine("Formatted PDF created successfully")
End Sub
End Module
With RawPrint, formatting beyond plain bytes means hand-authoring printer command sequences like "\x1B&l0O\x1B(s0p16.66h8.5v0s0b3T" and knowing the target printer's PCL or PostScript dialect. IronPDF uses standard HTML and CSS — complex layouts, fonts, colors, and images are fully supported without printer-specific knowledge.
Feature Comparison Summary
| Feature | RawPrint | IronPDF |
|---|---|---|
| PDF Creation | ||
| HTML to PDF | No | Yes |
| URL to PDF | No | Yes |
| Create from scratch | No | Yes |
| PDF Manipulation | ||
| Merge PDFs | No | Yes |
| Split PDFs | No | Yes |
| Add Watermarks | No | Yes |
| Edit Existing | No | Yes |
| Printing | ||
| Push RAW bytes to spooler | Yes | No |
| ESC/POS, ZPL, raw PCL | Yes | No |
| Print via OS print system | No | Yes |
| Platform | ||
| Windows | Yes | Yes |
| Linux | No | Yes |
| macOS | No | Yes |
| Docker | No | Yes |
| Other | ||
| Encryption / Security | No | Yes |
| Digital Signatures | No | Yes |
| PDF/A | No | Yes |
New Capabilities After Migration
After migrating to IronPDF, you gain capabilities that RawPrint cannot provide:
PDF Merging
var pdfs = pdfFiles.Select(f => PdfDocument.FromFile(f)).ToList();
var merged = PdfDocument.Merge(pdfs);
merged.SaveAs("complete.pdf");
var pdfs = pdfFiles.Select(f => PdfDocument.FromFile(f)).ToList();
var merged = PdfDocument.Merge(pdfs);
merged.SaveAs("complete.pdf");
Dim pdfs = pdfFiles.Select(Function(f) PdfDocument.FromFile(f)).ToList()
Dim merged = PdfDocument.Merge(pdfs)
merged.SaveAs("complete.pdf")
Print with Settings
var pdf = PdfDocument.FromFile("report.pdf");
pdf.Print(new PrintOptions
{
PrinterName = "HP LaserJet",
NumberOfCopies = 2,
DPI = 300,
GrayScale = false
});
var pdf = PdfDocument.FromFile("report.pdf");
pdf.Print(new PrintOptions
{
PrinterName = "HP LaserJet",
NumberOfCopies = 2,
DPI = 300,
GrayScale = false
});
Dim pdf = PdfDocument.FromFile("report.pdf")
pdf.Print(New PrintOptions With {
.PrinterName = "HP LaserJet",
.NumberOfCopies = 2,
.DPI = 300,
.GrayScale = False
})
Create and Print in One Workflow
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(@"
<h1>Invoice #12345</h1>
<p>Customer: John Doe</p>
<p>Amount: $150.00</p>
");
// Print directly
pdf.Print("HP LaserJet");
// Or save first
pdf.SaveAs("invoice.pdf");
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(@"
<h1>Invoice #12345</h1>
<p>Customer: John Doe</p>
<p>Amount: $150.00</p>
");
// Print directly
pdf.Print("HP LaserJet");
// Or save first
pdf.SaveAs("invoice.pdf");
Dim renderer = New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf("
<h1>Invoice #12345</h1>
<p>Customer: John Doe</p>
<p>Amount: $150.00</p>
")
' Print directly
pdf.Print("HP LaserJet")
' Or save first
pdf.SaveAs("invoice.pdf")
Migration Checklist
Pre-Migration
- Identify all RawPrint usage (
PrintRawFile,PrintRawStream) - Classify each call site: PDFs going to office printers are candidates for IronPDF; ESC/POS, ZPL, EPL, or hand-built PCL/PostScript bytes should stay on RawPrint
- Document printer names used in your application — IronPDF prints through the OS print system, so the names must still resolve
- Note any external PDF creation code that can be consolidated
- Obtain IronPDF license key from ironpdf.com
Code Updates
- Install IronPDF package:
dotnet add package IronPdf - Only remove RawPrint where there are no remaining raw-byte channels:
dotnet remove package RawPrint - Replace create-then-RawPrint pipelines with
ChromePdfRendererpluspdf.Print() - Consolidate PDF creation and printing into a single workflow on Windows
- Add license initialization at application startup
Testing
- Test printing to target printers
- Verify print quality
- Test multiple copies
- Test silent printing
- Cross-platform verification if needed

