How to Migrate from RawPrint to IronPDF in C#
Migrating from RawPrint to IronPDF transforms your document workflow from low-level printer byte transmission to a comprehensive PDF creation and printing solution. This guide provides a complete, step-by-step migration path that enables you to create, manipulate, and print PDFs with high-level APIs instead of manual printer handle management.
Why Migrate from RawPrint to IronPDF
Understanding RawPrint
RawPrint is a collection of implementations that enable sending raw data directly to a printer. It is essential for applications that require direct command transmission to printers, bypassing conventional printer drivers. This functionality is particularly useful in scenarios where specialized printers, such as label creators using ZPL (Zebra Programming Language) or EPL (Eltron Programming Language), are employed.
One strength of RawPrint is its simplicity in sending data streams directly to a printer. 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. This fundamental limitation makes it the wrong choice for most document generation scenarios.
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 planning .NET 10 and C# 14 adoption through 2025 and 2026, IronPDF provides cross-platform compatibility that RawPrint cannot offer.
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 IronPdfLicense Configuration
// 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 "Printer\|SendBytesToPrinter" --include="*.cs" .# Identify all RawPrint usage
grep -r "using RawPrint" --include="*.cs" .
grep -r "Printer\|SendBytesToPrinter" --include="*.cs" .Complete API Reference
Namespace Changes
// Before: RawPrint (Windows interop)
using System.Runtime.InteropServices;
using System.Drawing.Printing;
// After: IronPDF
using IronPdf;// Before: RawPrint (Windows interop)
using System.Runtime.InteropServices;
using System.Drawing.Printing;
// After: IronPDF
using IronPdf;Core API Mappings
| RawPrint | IronPDF | Notes |
|---|---|---|
Printer.SendBytesToPrinter() | pdf.Print() | High-level printing |
Printer.OpenPrinter() | N/A | Not needed |
Printer.ClosePrinter() | N/A | Automatic |
Printer.StartDocPrinter() | N/A | Automatic |
Printer.WritePrinter() | N/A | Automatic |
Printer.EndDocPrinter() | N/A | Automatic |
| N/A | ChromePdfRenderer | Create PDFs |
| N/A | PdfDocument.Merge() | Merge PDFs |
| N/A | pdf.ApplyWatermark() | Add watermarks |
Code Migration Examples
Example 1: HTML to PDF Conversion
Before (RawPrint):
// NuGet: Install-Package System.Drawing.Common
using System;
using System.Drawing;
using System.Drawing.Printing;
using System.Runtime.InteropServices;
using System.Text;
class RawPrinterHelper
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class DOCINFOA
{
[MarshalAs(UnmanagedType.LPStr)] public string pDocName;
[MarshalAs(UnmanagedType.LPStr)] public string pOutputFile;
[MarshalAs(UnmanagedType.LPStr)] public string pDataType;
}
[DllImport("winspool.Drv", EntryPoint = "OpenPrinterA", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern bool OpenPrinter([MarshalAs(UnmanagedType.LPStr)] string szPrinter, out IntPtr hPrinter, IntPtr pd);
[DllImport("winspool.Drv", EntryPoint = "ClosePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern bool ClosePrinter(IntPtr hPrinter);
[DllImport("winspool.Drv", EntryPoint = "StartDocPrinterA", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern bool StartDocPrinter(IntPtr hPrinter, Int32 level, [In, MarshalAs(UnmanagedType.LPStruct)] DOCINFOA di);
[DllImport("winspool.Drv", EntryPoint = "EndDocPrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern bool EndDocPrinter(IntPtr hPrinter);
[DllImport("winspool.Drv", EntryPoint = "StartPagePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern bool StartPagePrinter(IntPtr hPrinter);
[DllImport("winspool.Drv", EntryPoint = "EndPagePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern bool EndPagePrinter(IntPtr hPrinter);
[DllImport("winspool.Drv", EntryPoint = "WritePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern bool WritePrinter(IntPtr hPrinter, IntPtr pBytes, Int32 dwCount, out Int32 dwWritten);
public static bool SendStringToPrinter(string szPrinterName, string szString)
{
IntPtr pBytes;
Int32 dwCount;
dwCount = szString.Length;
pBytes = Marshal.StringToCoTaskMemAnsi(szString);
IntPtr hPrinter;
if (OpenPrinter(szPrinterName, out hPrinter, IntPtr.Zero))
{
DOCINFOA di = new DOCINFOA();
di.pDocName = "HTML Document";
di.pDataType = "RAW";
if (StartDocPrinter(hPrinter, 1, di))
{
if (StartPagePrinter(hPrinter))
{
Int32 dwWritten;
WritePrinter(hPrinter, pBytes, dwCount, out dwWritten);
EndPagePrinter(hPrinter);
}
EndDocPrinter(hPrinter);
}
ClosePrinter(hPrinter);
Marshal.FreeCoTaskMem(pBytes);
return true;
}
return false;
}
}
class Program
{
static void Main()
{
string html = "<html><body><h1>Hello World</h1></body></html>";
// RawPrint cannot directly convert HTML to PDF
// It sends raw data to printer, no PDF generation capability
RawPrinterHelper.SendStringToPrinter("Microsoft Print to PDF", html);
}
}// NuGet: Install-Package System.Drawing.Common
using System;
using System.Drawing;
using System.Drawing.Printing;
using System.Runtime.InteropServices;
using System.Text;
class RawPrinterHelper
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class DOCINFOA
{
[MarshalAs(UnmanagedType.LPStr)] public string pDocName;
[MarshalAs(UnmanagedType.LPStr)] public string pOutputFile;
[MarshalAs(UnmanagedType.LPStr)] public string pDataType;
}
[DllImport("winspool.Drv", EntryPoint = "OpenPrinterA", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern bool OpenPrinter([MarshalAs(UnmanagedType.LPStr)] string szPrinter, out IntPtr hPrinter, IntPtr pd);
[DllImport("winspool.Drv", EntryPoint = "ClosePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern bool ClosePrinter(IntPtr hPrinter);
[DllImport("winspool.Drv", EntryPoint = "StartDocPrinterA", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern bool StartDocPrinter(IntPtr hPrinter, Int32 level, [In, MarshalAs(UnmanagedType.LPStruct)] DOCINFOA di);
[DllImport("winspool.Drv", EntryPoint = "EndDocPrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern bool EndDocPrinter(IntPtr hPrinter);
[DllImport("winspool.Drv", EntryPoint = "StartPagePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern bool StartPagePrinter(IntPtr hPrinter);
[DllImport("winspool.Drv", EntryPoint = "EndPagePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern bool EndPagePrinter(IntPtr hPrinter);
[DllImport("winspool.Drv", EntryPoint = "WritePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern bool WritePrinter(IntPtr hPrinter, IntPtr pBytes, Int32 dwCount, out Int32 dwWritten);
public static bool SendStringToPrinter(string szPrinterName, string szString)
{
IntPtr pBytes;
Int32 dwCount;
dwCount = szString.Length;
pBytes = Marshal.StringToCoTaskMemAnsi(szString);
IntPtr hPrinter;
if (OpenPrinter(szPrinterName, out hPrinter, IntPtr.Zero))
{
DOCINFOA di = new DOCINFOA();
di.pDocName = "HTML Document";
di.pDataType = "RAW";
if (StartDocPrinter(hPrinter, 1, di))
{
if (StartPagePrinter(hPrinter))
{
Int32 dwWritten;
WritePrinter(hPrinter, pBytes, dwCount, out dwWritten);
EndPagePrinter(hPrinter);
}
EndDocPrinter(hPrinter);
}
ClosePrinter(hPrinter);
Marshal.FreeCoTaskMem(pBytes);
return true;
}
return false;
}
}
class Program
{
static void Main()
{
string html = "<html><body><h1>Hello World</h1></body></html>";
// RawPrint cannot directly convert HTML to PDF
// It sends raw data to printer, no PDF generation capability
RawPrinterHelper.SendStringToPrinter("Microsoft Print to PDF", html);
}
}After (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
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()
{
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");
}
}This example demonstrates the fundamental architectural difference. RawPrint requires 60+ lines of code with multiple DLL imports from winspool.Drv, manual printer handle management (OpenPrinter, StartDocPrinter, WritePrinter, EndDocPrinter, ClosePrinter), and memory marshaling—and it still cannot create a PDF. It only sends raw data to the printer with no rendering capability.
IronPDF accomplishes the task in 5 lines: create a ChromePdfRenderer, call RenderHtmlAsPdf(), and SaveAs(). See the HTML to PDF documentation for comprehensive examples.
Example 2: URL to PDF Conversion
Before (RawPrint):
// NuGet: Install-Package System.Drawing.Common
using System;
using System.Net;
using System.Runtime.InteropServices;
using System.Text;
class RawPrinterHelper
{
// ... (same DLL imports as above) ...
public static bool SendStringToPrinter(string szPrinterName, string szString)
{
IntPtr pBytes = Marshal.StringToCoTaskMemAnsi(szString);
IntPtr hPrinter;
if (OpenPrinter(szPrinterName, out hPrinter, IntPtr.Zero))
{
DOCINFOA di = new DOCINFOA();
di.pDocName = "Web Page";
di.pDataType = "RAW";
if (StartDocPrinter(hPrinter, 1, di))
{
if (StartPagePrinter(hPrinter))
{
Int32 dwWritten;
WritePrinter(hPrinter, pBytes, szString.Length, out dwWritten);
EndPagePrinter(hPrinter);
}
EndDocPrinter(hPrinter);
}
ClosePrinter(hPrinter);
Marshal.FreeCoTaskMem(pBytes);
return true;
}
return false;
}
}
class Program
{
static void Main()
{
// RawPrint cannot render web pages - only sends raw text/data
// This would just print HTML source code, not rendered content
using (WebClient client = new WebClient())
{
string htmlSource = client.DownloadString("https://example.com");
// This prints raw HTML, not a rendered PDF
RawPrinterHelper.SendStringToPrinter("Microsoft Print to PDF", htmlSource);
Console.WriteLine("Raw HTML sent to printer (not rendered)");
}
}
}// NuGet: Install-Package System.Drawing.Common
using System;
using System.Net;
using System.Runtime.InteropServices;
using System.Text;
class RawPrinterHelper
{
// ... (same DLL imports as above) ...
public static bool SendStringToPrinter(string szPrinterName, string szString)
{
IntPtr pBytes = Marshal.StringToCoTaskMemAnsi(szString);
IntPtr hPrinter;
if (OpenPrinter(szPrinterName, out hPrinter, IntPtr.Zero))
{
DOCINFOA di = new DOCINFOA();
di.pDocName = "Web Page";
di.pDataType = "RAW";
if (StartDocPrinter(hPrinter, 1, di))
{
if (StartPagePrinter(hPrinter))
{
Int32 dwWritten;
WritePrinter(hPrinter, pBytes, szString.Length, out dwWritten);
EndPagePrinter(hPrinter);
}
EndDocPrinter(hPrinter);
}
ClosePrinter(hPrinter);
Marshal.FreeCoTaskMem(pBytes);
return true;
}
return false;
}
}
class Program
{
static void Main()
{
// RawPrint cannot render web pages - only sends raw text/data
// This would just print HTML source code, not rendered content
using (WebClient client = new WebClient())
{
string htmlSource = client.DownloadString("https://example.com");
// This prints raw HTML, not a rendered PDF
RawPrinterHelper.SendStringToPrinter("Microsoft Print to PDF", htmlSource);
Console.WriteLine("Raw HTML sent to printer (not rendered)");
}
}
}After (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
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()
{
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");
}
}RawPrint cannot render web pages—it only sends raw text/data. The RawPrint approach downloads HTML source and sends it directly to the printer, resulting in raw HTML code being printed, 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 System.Drawing.Common
using System;
using System.Drawing.Printing;
using System.Runtime.InteropServices;
using System.Text;
class RawPrinterHelper
{
// ... (same DLL imports) ...
public static bool SendBytesToPrinter(string szPrinterName, byte[] pBytes)
{
IntPtr pUnmanagedBytes = Marshal.AllocCoTaskMem(pBytes.Length);
Marshal.Copy(pBytes, 0, pUnmanagedBytes, pBytes.Length);
IntPtr hPrinter;
if (OpenPrinter(szPrinterName, out hPrinter, IntPtr.Zero))
{
DOCINFOA di = new DOCINFOA();
di.pDocName = "Raw Document";
di.pDataType = "RAW";
if (StartDocPrinter(hPrinter, 1, di))
{
if (StartPagePrinter(hPrinter))
{
Int32 dwWritten;
WritePrinter(hPrinter, pUnmanagedBytes, pBytes.Length, out dwWritten);
EndPagePrinter(hPrinter);
}
EndDocPrinter(hPrinter);
}
ClosePrinter(hPrinter);
Marshal.FreeCoTaskMem(pUnmanagedBytes);
return true;
}
return false;
}
}
class Program
{
static void Main()
{
// RawPrint requires manual PCL/PostScript commands for formatting
string pclCommands = "\x1B&l0O\x1B(s0p16.66h8.5v0s0b3T";
string text = "Plain text document - limited formatting";
byte[] data = Encoding.ASCII.GetBytes(pclCommands + text);
RawPrinterHelper.SendBytesToPrinter("HP LaserJet", data);
}
}// NuGet: Install-Package System.Drawing.Common
using System;
using System.Drawing.Printing;
using System.Runtime.InteropServices;
using System.Text;
class RawPrinterHelper
{
// ... (same DLL imports) ...
public static bool SendBytesToPrinter(string szPrinterName, byte[] pBytes)
{
IntPtr pUnmanagedBytes = Marshal.AllocCoTaskMem(pBytes.Length);
Marshal.Copy(pBytes, 0, pUnmanagedBytes, pBytes.Length);
IntPtr hPrinter;
if (OpenPrinter(szPrinterName, out hPrinter, IntPtr.Zero))
{
DOCINFOA di = new DOCINFOA();
di.pDocName = "Raw Document";
di.pDataType = "RAW";
if (StartDocPrinter(hPrinter, 1, di))
{
if (StartPagePrinter(hPrinter))
{
Int32 dwWritten;
WritePrinter(hPrinter, pUnmanagedBytes, pBytes.Length, out dwWritten);
EndPagePrinter(hPrinter);
}
EndDocPrinter(hPrinter);
}
ClosePrinter(hPrinter);
Marshal.FreeCoTaskMem(pUnmanagedBytes);
return true;
}
return false;
}
}
class Program
{
static void Main()
{
// RawPrint requires manual PCL/PostScript commands for formatting
string pclCommands = "\x1B&l0O\x1B(s0p16.66h8.5v0s0b3T";
string text = "Plain text document - limited formatting";
byte[] data = Encoding.ASCII.GetBytes(pclCommands + text);
RawPrinterHelper.SendBytesToPrinter("HP LaserJet", data);
}
}After (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
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()
{
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");
}
}RawPrint requires manual PCL/PostScript commands ("\x1B&l0O\x1B(s0p16.66h8.5v0s0b3T") for even basic formatting. Developers must have deep understanding of the printer's command language. IronPDF uses standard HTML and CSS for formatting—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 | ||
| Print PDF | Yes (raw) | Yes (high-level) |
| Print Dialog | No | Yes |
| Multiple Copies | Limited | Yes |
| DPI Control | No | Yes |
| Duplex | No | Yes |
| Platform | ||
| Windows | Yes | Yes |
| Linux | No | Yes |
| macOS | No | Yes |
| Docker | No | Yes |
| Other | ||
| 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");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
});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");Migration Checklist
Pre-Migration
- Identify all RawPrint usage (
SendBytesToPrinter,OpenPrinter, etc.) - Document printer names used in your application
- Note any external PDF creation code that can be consolidated
- Obtain IronPDF license key from ironpdf.com
Code Updates
- Remove RawPrint package:
dotnet remove package RawPrint - Install IronPdf package:
dotnet add package IronPdf - Replace raw printing with
pdf.Print() - Remove manual handle management (
OpenPrinter,ClosePrinter, etc.) - Consolidate PDF creation and printing into single workflow
- 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






