Skip to footer content
MIGRATION GUIDES

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:

  1. No PDF Creation: RawPrint focuses solely on data transmission, lacking functionality for PDF creation, rendering, or manipulation.

  2. 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.

  3. Platform-Specific: It depends on Windows print spoolers, limiting its cross-platform applicability.

  4. No Document Processing: Just byte transmission with no rendering capabilities.

  5. Limited Control: Minimal print job configuration options.

RawPrint vs IronPDF Comparison

FeatureRawPrintIronPDF
FunctionalitySends raw print data directly to the printerComprehensive PDF creation and manipulation
Use CaseSpecialized printing like labelsGeneral document management and creation
Platform DependencyWindows-specificCross-platform
ComplexityLow-level, requires printer command knowledgeHigh-level, user-friendly API
PDF CreationNoYes
Create PDF from HTMLNoYes
Create PDF from URLNoYes
Edit/Modify PDFsNoYes
Merge/Split PDFsNoYes
Print Existing PDFYes (raw bytes)Yes (high-level API)
Print ControlBasicFull options
Ideal ForDirect printer access needsPDF-related tasks in web and desktop apps
FlexibilityLimited due to raw byte handlingExtensive 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

  1. .NET Environment: .NET Framework 4.6.2+ or .NET Core 3.1+ / .NET 5/6/7/8/9+
  2. NuGet Access: Ability to install NuGet packages
  3. 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
SHELL

License Configuration

// Add at application startup
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
// Add at application startup
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
$vbLabelText   $csharpLabel

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" .
SHELL

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;
$vbLabelText   $csharpLabel

Core API Mappings

RawPrintIronPDFNotes
Printer.SendBytesToPrinter()pdf.Print()High-level printing
Printer.OpenPrinter()N/ANot needed
Printer.ClosePrinter()N/AAutomatic
Printer.StartDocPrinter()N/AAutomatic
Printer.WritePrinter()N/AAutomatic
Printer.EndDocPrinter()N/AAutomatic
N/AChromePdfRendererCreate PDFs
N/APdfDocument.Merge()Merge PDFs
N/Apdf.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);
    }
}
$vbLabelText   $csharpLabel

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

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

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

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);
    }
}
$vbLabelText   $csharpLabel

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

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

FeatureRawPrintIronPDF
PDF Creation
HTML to PDFNoYes
URL to PDFNoYes
Create from scratchNoYes
PDF Manipulation
Merge PDFsNoYes
Split PDFsNoYes
Add WatermarksNoYes
Edit ExistingNoYes
Printing
Print PDFYes (raw)Yes (high-level)
Print DialogNoYes
Multiple CopiesLimitedYes
DPI ControlNoYes
DuplexNoYes
Platform
WindowsYesYes
LinuxNoYes
macOSNoYes
DockerNoYes
Other
SecurityNoYes
Digital SignaturesNoYes
PDF/ANoYes

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");
$vbLabelText   $csharpLabel

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
});
$vbLabelText   $csharpLabel

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");
$vbLabelText   $csharpLabel

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

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