Jak przeprowadzić migrację z RawPrint do IronPDF w języku C#
Przejście zRawPrintdo IronPDF to bardziej modernizacja niż zamiana:RawPrinti IronPDF rozwiązują różne problemy, a uczciwe określanie dla większości zespołów to "uzupełnienie", a nie "zamiana". Przewodnik omawia przypadki, gdzie IronPDF faktycznie zastępuje pipelineRawPrint(tworzenie PDF, a następnie przepychanie go w Windows), i wskazuje przypadki, w których należy pozostawićRawPrint(ESC/POS, ZPL, EPL, surowe PCL).
Dlaczego warto przejść zRawPrintna IronPDF
Zrozumienie RawPrint
RawPrint to pakiet NuGet RawPrint (frogmorecs/RawPrint, v0.5.0, ostatnie wydanie we wrześniu 2019, teraz niezarejestrowany/legacy na nuget.org). Jest to cienka nakładka P/Invoke nad winspool.Drv, która przesyła strumień bajtów bezpośrednio do kolejki wydrukówWindowsz typem danych RAW. Publiczne API jest małe: klasa Printer implementująca IPrinter w przestrzeni nazw RawPrint, udostępniająca przeciążenia PrintRawFile i PrintRawStream. Podstawowe wywołania Win32 (OpenPrinter, StartDocPrinter, WritePrinter, EndDocPrinter, ClosePrinter) są ukryte za tym interfejsem — nie piszesz ich samodzielnie, korzystając z pakietu.
To sprawia, żeRawPrintjest dobrym rozwiązaniem dla drukarek paragonów ESC/POS, drukarek etykiet Zebra ZPL/EPL i starszych zadań PCL/PostScript, gdzie już wytworzono bajty, których spodziewa się firmware drukarki. Dla programistów tworzących oprogramowanie przeznaczone dla środowiskWindowsi wymagających bezpośredniej komunikacji z drukarką,RawPrintoferuje wydajną ścieżkę omijającą warstwy pośredniczące, takie jak sterowniki lub interfejsy graficzne.
JednakRawPrintnie jest biblioteką PDF — po prostu przesyła dane do drukarek. Jeśli Twoja aplikacja obecnie buduje PDF w innej bibliotece, a następnie przekazuje go do RawPrint, ten cały pipeline może zazwyczaj złożyć się w IronPDF na systemie Windows.
Główny problem: brak możliwości tworzenia plików PDF
RawPrint ma istotne ograniczenia, które sprawiają, że nie nadaje się do nowoczesnych procesów obsługi dokumentów:
-
Brak tworzenia plików PDF:RawPrintskupia się wyłącznie na transmisji danych, nie posiada funkcji tworzenia, renderowania ani edycji plików PDF.
-
Bardzo niski poziom: Ponieważ programiści mają do czynienia bezpośrednio z surowymi bajtami, muszą oni posiadać dogłębną znajomość języka poleceń drukarki, co sprawia, że rozwiązanie to jest mniej odpowiednie do prostych zadań związanych z drukowaniem dokumentów.
-
Zależność od platformy: Rozwiązanie opiera się na buforach wydruku systemu Windows, co ogranicza jego zastosowanie na różnych platformach.
-
Brak przetwarzania dokumentów: Tylko transmisja bajtów bez możliwości renderowania.
- Ograniczona kontrola: Minimalne opcje konfiguracji zadań drukowania.
PorównanieRawPrinti IronPDF
| Funkcja | RawPrint | IronPDF |
|---|---|---|
| Funkcjonalność | Wysyła surowe dane drukowania bezpośrednio do drukarki | Kompleksowe tworzenie i edycja plików PDF |
| Przykład zastosowania | Specjalistyczne wydruki, takie jak etykiety | Ogólne zarządzanie dokumentami i ich tworzenie |
| Zależność od platformy | Specyficzne dla systemuWindows | Wielopłatformowe |
| Złożoność | Niski poziom, wymaga znajomości poleceń drukarki | Wysokopoziomowy, przyjazny dla użytkownika interfejs API |
| Tworzenie plików PDF | Nie | Tak |
| Utwórz plik PDF z HTML | Nie | Tak |
| Utwórz plik PDF z adresu URL | Nie | Tak |
| Edytuj/modyfikuj pliki PDF | Nie | Tak |
| Łączenie/dzielenie plików PDF | Nie | Tak |
| Wydrukuj istniejący plik PDF | Tak (surowe bajty) | Tak (API wysokiego poziomu) |
| Kontrola drukowania | Podstawowe | Pełne opcje |
| Idealny dla | Wymagania dotyczące bezpośredniego dostępu do drukarki | Zadania związane z plikami PDF w aplikacjach internetowych i desktopowych |
| Elastyczność | Ograniczone ze względu na obsługę surowych bajtów | Rozbudowany, z wieloma funkcjami |
W przeciwieństwie do RawPrint,IronPDF oferuje solidny i wszechstronny interfejs API do kompleksowej obsługi plików PDF. Jako uznana marka w środowisku .NET,IronPDF umożliwia programistom łatwe tworzenie, edycję i konwersję plików PDF na różnych platformach.
Dla zespołów celujących w nowoczesne .NET,IronPDF zapewnia zgodność z wieloma platformami, której RawPrint, zgodnie z założeniem, nie oferuje.
Zanim zaczniesz
Wymagania wstępne
- Środowisko .NET: .NET Framework 4.6.2+ lub .NET Core 3.1+ / .NET 5/6/7/8/9+
- Dostęp do NuGet: Możliwość instalowania pakietów NuGet
- Licencja IronPDF: Uzyskaj klucz licencyjny na stronie ironpdf.com
Zmiany w pakiecie NuGet
# Remove RawPrint
dotnet remove package RawPrint
# Install IronPDF
dotnet add package IronPdf
# Remove RawPrint
dotnet remove package RawPrint
# Install IronPDF
dotnet add package IronPdf
Konfiguracja licencji
// 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"
Znajdź zastosowanie RawPrint
# Identify allRawPrintusage
grep -r "using RawPrint" --include="*.cs" .
grep -r "PrintRawFile\|PrintRawStream" --include="*.cs" .
# Identify allRawPrintusage
grep -r "using RawPrint" --include="*.cs" .
grep -r "PrintRawFile\|PrintRawStream" --include="*.cs" .
Uwaga: ręcznie stworzone nakładki P/Invoke wokół winspool.Drv czasem używają nazwy klasy RawPrinterHelper i wyglądają powierzchownie podobnie do użycia RawPrint, ale nie są to te same pakiety — wywołują bezpośrednio kolejkę Win32. Sam pakiet ujawnia jedynie IPrinter z PrintRawFile i PrintRawStream.
Kompletna dokumentacija API
Zmiany w przestrzeni nazw
// Before: RawPrint
using RawPrint;
// After: IronPDF
using IronPdf;
// Before: RawPrint
using RawPrint;
// After: IronPDF
using IronPdf;
Imports IronPdf
Mapowania podstawowych interfejsów API
| RawPrint (prawdziwe publiczne API) | IronPDF | Uwagi |
|---|---|---|
new Printer() / IPrinter |
new ChromePdfRenderer() / PdfDocument |
RawPrint wysyła bajty;IronPDF generuje PDFy |
printer.PrintRawFile(name, path, paused) |
PdfDocument.FromFile(path).Print() |
IronPDF przetwarza na nowo do systemu drukowania OS; nie RAW |
printer.PrintRawStream(name, stream, doc, paused) |
new PdfDocument(stream).Print() |
To samo zastrzeżenie |
printer.OnJobCreated zdarzenie |
n/d | Użyj opcji drukowania IronPDF zamiast tego |
| n/d | ChromePdfRenderer.RenderHtmlAsPdf() |
Tworzenie plików PDF |
| n/d | PdfDocument.Merge() |
Łączenie plików PDF |
| n/d | pdf.ApplyWatermark() |
Dodaj znaki wodne |
IronPDF drukuje poprzez przekazanie dokumentu do systemu operacyjnego, a nie strumieniowanie surowych bajtów do kolejki. Jeśli Twoja drukarka wymaga typu danych RAW (ESC/POS, ZPL, niektóre workflow PCL), to jest zadanie dlaRawPrinti IronPDF nie może go zastąpić.
Przykłady migracji kodu
Przykład 1: Konwersja HTML do PDF
Before (RawPrint):
// NuGet: Install-Package RawPrint
using System;
using System.IO;
using System.Text;
using RawPrint;
class Program
{
static void Main()
{
//RawPrintcannot 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()
{
//RawPrintcannot 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
Po (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
Niedopasowanie architekturalne widać nawet przy przyjaznym API pakietu:RawPrintwysyła bajty do kolejkiWindowsz typem danych RAW, więc przekazywanie mu HTML powoduje, że drukarka drukuje tekst źródłowy. IronPDF's ChromePdfRenderer faktycznie renderuje znacznik. Zobacz dokumentację HTML to PDF dla pełnych przykładów.
Przykład 2: Konwersja adresów URL do formatu PDF
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()
{
//RawPrintcannot 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()
{
//RawPrintcannot 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
Po (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 nie może renderować stron internetowych — po prostu przesyła bajty do kolejki. Pobieranie HTMLa i przepuszczanie go powoduje, że drukarka drukuje tekst źródłowy, a nie renderowaną treść. IronPDF's RenderUrlAsPdf() przechwytuje w pełni wykonaną stronę internetową z CSS, JavaScript i obrazami. Dowiedz się więcej z naszych samouczków.
Przykład 3: Formatowanie dokumentów
Before (RawPrint):
// NuGet: Install-Package RawPrint
using System;
using System.IO;
using System.Text;
using RawPrint;
class Program
{
static void Main()
{
//RawPrinthas 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()
{
//RawPrinthas 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
Module Program
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 Module
Po (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
Z RawPrint, formatowanie poza zwykłe bajty oznacza ręczne pisanie sekwencji poleceń drukarki jak "\x1B&l0O\x1B(s0p16.66h8.5v0s0b3T" i znajomość dialektu PCL lub PostScript docelowej drukarki.IronPDF używa standardowego HTML i CSS — złożone układy, czcionki, kolory oraz obrazy są w pełni obsługiwane bez wiedzy specyficznej dla drukarek.
Podsumowanie porównania funkcji
| Funkcja | RawPrint | IronPDF |
|---|---|---|
| Tworzenie plików PDF | ||
| HTML do PDF | Nie | Tak |
| URL do pliku PDF | Nie | Tak |
| Stwórz od podstaw | Nie | Tak |
| Manipulacja plikami PDF | ||
| Łączenie plików PDF | Nie | Tak |
| Podział plików PDF | Nie | Tak |
| Dodaj znaki wodne | Nie | Tak |
| Edytuj istniejący | Nie | Tak |
| Drukowanie | ||
| Przesyłanie surowych bajtów do kolejki | Tak | Nie |
| ESC/POS, ZPL, surowe PCL | Tak | Nie |
| Drukowanie przez system drukowania OS | Nie | Tak |
| Platforma | ||
| Windows | Tak | Tak |
| Linux | Nie | Tak |
| macOS | Nie | Tak |
| Docker | Nie | Tak |
| Inne | ||
| Szyfrowanie / Bezpieczeństwo | Nie | Tak |
| Podpisy cyfrowe | Nie | Tak |
| PDF/A | Nie | Tak |
Nowe możliwości po migracji
Po migracji do IronPDF zyskujesz możliwości, którychRawPrintnie może zapewnić:
Łączenie plików PDF
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")
Drukowanie z ustawieniami
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
})
Tworzenie i drukowanie w jednym 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")
Lista kontrolna migracji
Przed migracją
- Identyfikacja całego użyciaRawPrint(
PrintRawFile,PrintRawStream) - Zaklasyfikuj każde miejsce wywołania: PDF-y do drukarek biurowych to kandydaci do IronPDF; ESC/POS, ZPL, EPL lub ręcznie zbudowane bajty PCL/PostScript powinny pozostać na RawPrint
- Udokumentuj nazwy drukarek używanych w twojej aplikacji —IronPDF drukuje przez system drukowania OS, więc nazwy muszą być rozpoznawane
- Zanotuj wszelkie zewnętrzne kody tworzenia PDF, które można skonsolidować
- Uzyskaj klucz licencyjny IronPDF ze strony ironpdf.com
Aktualizacje kodu
- Zainstaluj pakiet IronPDF:
dotnet add package IronPdf - UsuńRawPrinttylko tam, gdzie nie ma pozostałych kanałów bajtów RAW:
dotnet remove package RawPrint - Zamień pipeline create-then-RawPrint na
ChromePdfRendererpluspdf.Print() - Skonsoliduj tworzenie i drukowanie PDF w jedno workflow na Windows
- Dodaj inicjalizację licencji podczas uruchamiania aplikacji
Testowanie
- Przetestuj drukowanie na docelowych drukarkach
- Zweryfikuj jakość druku
- Przetestuj wiele kopii
- Przetestuj ciche drukowanie
- Weryfikacja międzyplatformowa, jeśli wymagane

