Przejdź do treści stopki
PRZEWODNIKI MIGRACJI

Jak przeprowadzić migrację z PDFPrinting.NET do IronPDF w języku C#

Przejście z PDFPrinting.NET na IronPDF rozszerza możliwości obsługi plików PDF z biblioteki służącej wyłącznie do drukowania na kompleksowe rozwiązanie, które obsługuje cały cykl życia plików PDF, w tym tworzenie, edycję, wyodrębnianie, zabezpieczenia i drukowanie. Niniejszy przewodnik zawiera kompletną, szczegółową ścieżkę migracji, która pozwala zachować istniejące procesy drukowania, dodając jednocześnie funkcje generowania plików PDF, konwersji do formatu HTML oraz obsługi wielu platform.

Dlaczego warto przejść z PDFPrinting.NET na IronPDF

Zrozumienie PDFPrinting.NET

PDFPrinting.NET (Terminalworks; NuGet PdfPrintingNet) jest wyspecjalizowaną biblioteką skupioną na cichym drukowaniu PDF w środowiskach Windows. Jako dedykowane narzedzie skoncentrowane na cichym drukowaniu istniejacych PDF, upraszcza zadanie wysylania dokumentow do drukarki programowo bez interwencji uzytkownika. Nowszym punktem wejścia jest klasa PdfPrint; starszy kod może nadal odnosić się do przestarzałego TerminalWorks.PDFPrinting.PDFPrinter.

Glowne atuty to ciche drukowanie — omijanie zwyklych okienek dialogowych drukowania, dzieki czemu w pelni zautomatyzowane przeplywy pracy moga dzialac bez nadzoru.

Ograniczenie skoncentrowane na drukowaniu

PDFPrinting.NET koncentruje sie na waskim zestawie operacji i nie tworzy nowych tresci PDF. Jego zakres to drukowanie, przegladanie, podstawowa edycja i rastrowanie istniejacych dokumentow:

  1. Skoncentrowany na drukowaniu: Nie tworzy nowych tresci PDF — tylko drukuje, przeglada, edytuje i rastrowi istniejace PDF.

  2. Drukowanie tylko w Windows: Zwiazane z infrastruktura drukowania Windows, co ogranicza uzytecznosc miedzyplatformowa.

  3. Brak API HTML/URL-to-PDF: Nie ma HtmlToPdfConverter ani klasy WebPageToPdfConverter — te funkcje nie istnieją w powierzchni API.

  4. Ograniczona manipulacja: Podstawowe scalanie/dzielenie/wyodrębnianie jest dostępne za pośrednictwem PdfPrintDocument; brak funkcji znaku wodnego czy nowoczesnego tworzenia tresci.

  5. Brak wszechstronnej powierzchni do ekstrakcji tekstu.

  6. Brak wypelniania lub splaszczania formularzy.

Porównanie PDFPrinting.NET i IronPDF

Funkcja PDFPrinting.NET IronPDF
Podstawowa funkcjonalność Ciche drukowanie plików PDF Obsługa pełnego cyklu (tworzenie, edycja, PRINT)
Obsługa platform Tylko dla systemu Windows Wielopłatformowe
Możliwości tworzenia i edycji plików PDF Nie Tak
Konwersja HTML do PDF Nie Tak
Przydatność w zautomatyzowanych procesach Wysoka Wysoka
Dodatkowe zależności Wymaga drukarek Windows Wewnętrzny silnik przeglądarki do renderowania
Ciche drukowanie Tak Tak
Wyodrębnianie tekstu Nieobsługiwane Obsługiwane
Licencjonowanie Komercjalne Komercjalne

IronPDF oferuje bardziej kompleksowe rozwiązanie, obejmujące cały cykl życia obsługi plików PDF. Ułatwia tworzenie, edycję, konwersję i drukowanie dokumentów PDF, oferując programistom pełną Suite funkcji za pośrednictwem ujednoliconego interfejsu API. W przeciwieństwie do PDFPrinting.NET,IronPDF może być wdrażany na różnych platformach, co czyni go wszechstronnym wyborem dla aplikacji działających w zróżnicowanych środowiskach.

Dla zespolow uzywajacych nowoczesnego .NET,IronPDF dostarcza kompletne rozwiazanie PDF dzialajace w srodowisku Windows, Linux i macOS.


Zanim zaczniesz

Wymagania wstępne

  1. Środowisko .NET: .NET Framework 4.6.2+ lub .NET Core 3.1+ / .NET 5/6/7/8/9+
  2. Dostęp do NuGet: Możliwość instalowania pakietów NuGet
  3. Licencja IronPDF: Uzyskaj klucz licencyjny na stronie ironpdf.com

Zmiany w pakiecie NuGet

# Remove PDFPrinting.NET (the actual NuGet ID is PdfPrintingNet)
dotnet remove package PdfPrintingNet

# Install IronPDF
dotnet add package IronPdf
# Remove PDFPrinting.NET (the actual NuGet ID is PdfPrintingNet)
dotnet remove package PdfPrintingNet

# Install IronPDF
dotnet add package IronPdf
SHELL

Konfiguracja licencji

// Add at application startup (Program.cs or Startup.cs)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
// Add at application startup (Program.cs or Startup.cs)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
' Add at application startup (Program.vb or Startup.vb)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
$vbLabelText   $csharpLabel

Zidentyfikuj zastosowanie PDFPrinting.NET

# Find PDFPrinting.NET usage (newer + legacy namespaces)
grep -rE "PdfPrintingNet|TerminalWorks\.PDFPrinting|PdfPrint\b|PdfPrintDocument|PDFPrinter" --include="*.cs" .

# Find print-related code
grep -r "\.Print(\|PrinterName\|GetPrintDocument" --include="*.cs" .
# Find PDFPrinting.NET usage (newer + legacy namespaces)
grep -rE "PdfPrintingNet|TerminalWorks\.PDFPrinting|PdfPrint\b|PdfPrintDocument|PDFPrinter" --include="*.cs" .

# Find print-related code
grep -r "\.Print(\|PrinterName\|GetPrintDocument" --include="*.cs" .
SHELL

Kompletna dokumentacija API

Zmiany w przestrzeni nazw

// Before: PDFPrinting.NET
// Newer API:
using PdfPrintingNet;
// Older code may use:
using TerminalWorks.PDFPrinting;

// After: IronPDF
using IronPdf;
using IronPdf.Rendering;
using IronPdf.Printing;
// Before: PDFPrinting.NET
// Newer API:
using PdfPrintingNet;
// Older code may use:
using TerminalWorks.PDFPrinting;

// After: IronPDF
using IronPdf;
using IronPdf.Rendering;
using IronPdf.Printing;
' Before: PDFPrinting.NET
' Newer API:
Imports PdfPrintingNet
' Older code may use:
Imports TerminalWorks.PDFPrinting

' After: IronPDF
Imports IronPdf
Imports IronPdf.Rendering
Imports IronPdf.Printing
$vbLabelText   $csharpLabel

Mapowania klas podstawowych

PDFPrinting.NET IronPDF
PdfPrint (nowszy) / PDFPrinter (przestarzały) PdfDocument + Print()
PdfPrintDocument PdfDocument
(nie istnieje klasa HTML-to-PDF) ChromePdfRenderer.RenderHtmlAsPdf
(nie istnieje klasa URL-to-PDF) ChromePdfRenderer.RenderUrlAsPdf
Właściwości ustawień drukowania PrintSettings

Mapowanie metod drukowania

PDFPrinting.NET IronPDF
pdfPrint.Print(filePath) pdf.Print()
pdfPrint.PrinterName = "..."; pdfPrint.Print(path) pdf.Print(printerName)
new PdfPrintDocument(...) pdf.GetPrintDocument()
pdfPrint.Copies = n printSettings.NumberOfCopies = n
pdfPrint.Duplex = true printSettings.DuplexMode = Duplex.Vertical
pdfPrint.Collate = true printSettings.Collate = true

Nowe funkcje niedostępne w PDFPrinting.NET

Funkcja IronPDF Opis
renderer.RenderHtmlAsPdf(html) Konwersja HTML do PDF
renderer.RenderUrlAsPdf(url) Konwersja adresów URL do formatu PDF
PdfDocument.Merge(pdfs) Łączenie wielu plików PDF
pdf.ApplyWatermark(html) Dodaj znaki wodne
pdf.SecuritySettings.UserPassword Ochrona hasłem
pdf.ExtractAllText() Wyodrębnianie tekstu

Przykłady migracji kodu

Przykład 1: Konwersja HTML do PDF

Przed (PDFPrinting.NET): PDFPrinting.NET nie ma API HTML-to-PDF — nie ma klasy HtmlToPdfConverter. Najblizszy sposob pracy to wygenerowanie PDF z innej biblioteki, a nastepnie wydrukowanie lub przekazanie pliku:

// NuGet: Install-Package PdfPrintingNet
using PdfPrintingNet;
using System;

class Program
{
    static void Main()
    {
        // Step 1: Produce the PDF with another library (PDFPrinting.NET cannot).
        // Step 2: Print the existing PDF file.
        var pdfPrint = new PdfPrint("license-owner", "license-key");
        var status = pdfPrint.Print("output.pdf");
        Console.WriteLine($"Printed: {status}");
    }
}
// NuGet: Install-Package PdfPrintingNet
using PdfPrintingNet;
using System;

class Program
{
    static void Main()
    {
        // Step 1: Produce the PDF with another library (PDFPrinting.NET cannot).
        // Step 2: Print the existing PDF file.
        var pdfPrint = new PdfPrint("license-owner", "license-key");
        var status = pdfPrint.Print("output.pdf");
        Console.WriteLine($"Printed: {status}");
    }
}
Imports PdfPrintingNet
Imports System

Class Program
    Shared Sub Main()
        ' Step 1: Produce the PDF with another library (PDFPrinting.NET cannot).
        ' Step 2: Print the existing PDF file.
        Dim pdfPrint = New PdfPrint("license-owner", "license-key")
        Dim status = pdfPrint.Print("output.pdf")
        Console.WriteLine($"Printed: {status}")
    End Sub
End Class
$vbLabelText   $csharpLabel

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

Poniewaz PDFPrinting.NET nie moze w ogole tworzyc PDF, migracja nie jest rownowaznym zamiennikiem klasy — to przyjecie nowej mozliwosci. Metoda ChromePdfRenderer.RenderHtmlAsPdf() z IronPDF zwraca PdfDocument, który można manipulować (znaki wodne, scalanie, zabezpieczenia) przed zapisaniem przy użyciu SaveAs(). Wykorzystujac silnik oparty na Chromium,IronPDF odtwarza nowoczesne renderowanie CSS i JavaScript z duza dokladnoscia. Kompleksowe przykłady można znaleźć w dokumentacji dotyczącej konwersji HTML do PDF.

Przykład 2: Konwersja adresów URL do formatu PDF

Przed (PDFPrinting.NET): Nie ma klasy WebPageToPdfConverter — PDFPrinting.NET nie pobiera ani nie renderuje stron internetowych. Oddzielna biblioteka musi najpierw pobrac URL jako PDF; nastepnie PDFPrinting.NET moze wydrukowac powstaly plik:

// NuGet: Install-Package PdfPrintingNet
using PdfPrintingNet;
using System;

class Program
{
    static void Main()
    {
        // Step 1: Capture the URL with another library (PDFPrinting.NET cannot).
        // Step 2: Print the resulting PDF.
        var pdfPrint = new PdfPrint("license-owner", "license-key");
        var status = pdfPrint.Print("webpage.pdf");
        Console.WriteLine($"Printed: {status}");
    }
}
// NuGet: Install-Package PdfPrintingNet
using PdfPrintingNet;
using System;

class Program
{
    static void Main()
    {
        // Step 1: Capture the URL with another library (PDFPrinting.NET cannot).
        // Step 2: Print the resulting PDF.
        var pdfPrint = new PdfPrint("license-owner", "license-key");
        var status = pdfPrint.Print("webpage.pdf");
        Console.WriteLine($"Printed: {status}");
    }
}
Imports PdfPrintingNet
Imports System

Class Program
    Shared Sub Main()
        ' Step 1: Capture the URL with another library (PDFPrinting.NET cannot).
        ' Step 2: Print the resulting PDF.
        Dim pdfPrint As New PdfPrint("license-owner", "license-key")
        Dim status = pdfPrint.Print("webpage.pdf")
        Console.WriteLine($"Printed: {status}")
    End Sub
End Class
$vbLabelText   $csharpLabel

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 url = "https://www.example.com";
        var pdf = renderer.RenderUrlAsPdf(url);
        pdf.SaveAs("webpage.pdf");
        Console.WriteLine("PDF from URL 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 url = "https://www.example.com";
        var pdf = renderer.RenderUrlAsPdf(url);
        pdf.SaveAs("webpage.pdf");
        Console.WriteLine("PDF from URL created successfully");
    }
}
Imports IronPdf
Imports System

Module Program
    Sub Main()
        IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"

        Dim renderer As New ChromePdfRenderer()
        Dim url As String = "https://www.example.com"
        Dim pdf = renderer.RenderUrlAsPdf(url)
        pdf.SaveAs("webpage.pdf")
        Console.WriteLine("PDF from URL created successfully")
    End Sub
End Module
$vbLabelText   $csharpLabel

IronPDF używa jednej klasy ChromePdfRenderer zarówno dla ciągów HTML, jak i URL, z RenderUrlAsPdf() obsługującym przechwytywanie stron internetowych w jednym wywołaniu. Dowiedz się więcej z naszych samouczków.

Przykład 3: Nagłówki i stopki

Przed (PDFPrinting.NET): PDFPrinting.NET nie moze tworzyc naglowkow ani stopki — nie generuje PDF z HTML ani z innych zrodel, a takze nie oferuje API kompozycji naglowka/stopy. Jezeli twoj PDF juz je zawiera, biblioteka moze to wydrukowac:

// NuGet: Install-Package PdfPrintingNet
using PdfPrintingNet;
using System;

class Program
{
    static void Main()
    {
        // Headers/footers must already be baked into the PDF.
        var pdfPrint = new PdfPrint("license-owner", "license-key");
        pdfPrint.Print("report.pdf");
        Console.WriteLine("PDF with pre-existing headers/footers printed");
    }
}
// NuGet: Install-Package PdfPrintingNet
using PdfPrintingNet;
using System;

class Program
{
    static void Main()
    {
        // Headers/footers must already be baked into the PDF.
        var pdfPrint = new PdfPrint("license-owner", "license-key");
        pdfPrint.Print("report.pdf");
        Console.WriteLine("PDF with pre-existing headers/footers printed");
    }
}
Imports PdfPrintingNet
Imports System

Module Program
    Sub Main()
        ' Headers/footers must already be baked into the PDF.
        Dim pdfPrint As New PdfPrint("license-owner", "license-key")
        pdfPrint.Print("report.pdf")
        Console.WriteLine("PDF with pre-existing headers/footers printed")
    End Sub
End Module
$vbLabelText   $csharpLabel

Po (IronPDF):

// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Rendering;
using System;

class Program
{
    static void Main()
    {
        IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";

        var renderer = new ChromePdfRenderer();
        renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter()
        {
            HtmlFragment = "<div style='text-align:center'>Company Report</div>"
        };
        renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter()
        {
            HtmlFragment = "<div style='text-align:center'>Page {page} of {total-pages}</div>"
        };
        string html = "<html><body><h1>Document Content</h1></body></html>";
        var pdf = renderer.RenderHtmlAsPdf(html);
        pdf.SaveAs("report.pdf");
        Console.WriteLine("PDF with headers/footers created");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Rendering;
using System;

class Program
{
    static void Main()
    {
        IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";

        var renderer = new ChromePdfRenderer();
        renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter()
        {
            HtmlFragment = "<div style='text-align:center'>Company Report</div>"
        };
        renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter()
        {
            HtmlFragment = "<div style='text-align:center'>Page {page} of {total-pages}</div>"
        };
        string html = "<html><body><h1>Document Content</h1></body></html>";
        var pdf = renderer.RenderHtmlAsPdf(html);
        pdf.SaveAs("report.pdf");
        Console.WriteLine("PDF with headers/footers created");
    }
}
Imports IronPdf
Imports IronPdf.Rendering
Imports System

Module Program
    Sub Main()
        IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"

        Dim renderer As New ChromePdfRenderer()
        renderer.RenderingOptions.HtmlHeader = New HtmlHeaderFooter() With {
            .HtmlFragment = "<div style='text-align:center'>Company Report</div>"
        }
        renderer.RenderingOptions.HtmlFooter = New HtmlHeaderFooter() With {
            .HtmlFragment = "<div style='text-align:center'>Page {page} of {total-pages}</div>"
        }
        Dim html As String = "<html><body><h1>Document Content</h1></body></html>"
        Dim pdf = renderer.RenderHtmlAsPdf(html)
        pdf.SaveAs("report.pdf")
        Console.WriteLine("PDF with headers/footers created")
    End Sub
End Module
$vbLabelText   $csharpLabel

IronPDF używa obiektów HtmlHeaderFooter z właściwością HtmlFragment, która akceptuje pełne HTML, co pozwala na zaawansowane stylizowanie przy pomocy CSS. Miejsca wypełnienia, takie jak {page} i {total-pages}, są zastępowane w czasie renderowania.


Ważne uwagi dotyczące migracji

Miejsca na naglowki/stopy sa funkcja dostepna tylko w IronPDF

PDFPrinting.NET nie posiada w ogole API do tworzenia naglowkow ani stopek, wiec nie ma skladni placeholdera do migracji.IronPDF obsługuje miejsca wypełnienia {page} i {total-pages} wewnątrz HtmlHeaderFooter.HtmlFragment:

//IronPDF placeholders
"Page {page} of {total-pages}"
//IronPDF placeholders
"Page {page} of {total-pages}"
$vbLabelText   $csharpLabel

Wzorzec "Load-Then-PRINT"

PDFPrinting.NET przekazuje ścieżki plików bezpośrednio do Print();IronPDF najpierw laduje dokument:

// PDFPrinting.NET: Direct path to Print()
pdfPrint.Print("document.pdf");

// IronPDF: Load first, then operate
var pdf = PdfDocument.FromFile("document.pdf");
pdf.Print();
// PDFPrinting.NET: Direct path to Print()
pdfPrint.Print("document.pdf");

// IronPDF: Load first, then operate
var pdf = PdfDocument.FromFile("document.pdf");
pdf.Print();
' PDFPrinting.NET: Direct path to Print()
pdfPrint.Print("document.pdf")

' IronPDF: Load first, then operate
Dim pdf = PdfDocument.FromFile("document.pdf")
pdf.Print()
$vbLabelText   $csharpLabel

Migracja ustawień drukowania

PDFPrinting.NET używa właściwości na PdfPrint;IronPDF wykorzystuje obiekt ustawień:

// PDFPrinting.NET: Properties on PdfPrint
pdfPrint.Copies = 2;
pdfPrint.Duplex = true;

// IronPDF: Settings object
var settings = new PrintSettings
{
    NumberOfCopies = 2,
    DuplexMode = System.Drawing.Printing.Duplex.Vertical
};
pdf.Print(settings);
// PDFPrinting.NET: Properties on PdfPrint
pdfPrint.Copies = 2;
pdfPrint.Duplex = true;

// IronPDF: Settings object
var settings = new PrintSettings
{
    NumberOfCopies = 2,
    DuplexMode = System.Drawing.Printing.Duplex.Vertical
};
pdf.Print(settings);
' PDFPrinting.NET: Properties on PdfPrint
pdfPrint.Copies = 2
pdfPrint.Duplex = True

' IronPDF: Settings object
Dim settings As New PrintSettings With {
    .NumberOfCopies = 2,
    .DuplexMode = System.Drawing.Printing.Duplex.Vertical
}
pdf.Print(settings)
$vbLabelText   $csharpLabel

Nowe możliwości po migracji

Po migracji do IronPDF zyskujesz możliwości, których PDFPrinting.NET nie jest w stanie zapewnić:

Łączenie plików PDF

var pdf1 = PdfDocument.FromFile("document1.pdf");
var pdf2 = PdfDocument.FromFile("document2.pdf");
var merged = PdfDocument.Merge(pdf1, pdf2);
merged.SaveAs("merged.pdf");
var pdf1 = PdfDocument.FromFile("document1.pdf");
var pdf2 = PdfDocument.FromFile("document2.pdf");
var merged = PdfDocument.Merge(pdf1, pdf2);
merged.SaveAs("merged.pdf");
Dim pdf1 = PdfDocument.FromFile("document1.pdf")
Dim pdf2 = PdfDocument.FromFile("document2.pdf")
Dim merged = PdfDocument.Merge(pdf1, pdf2)
merged.SaveAs("merged.pdf")
$vbLabelText   $csharpLabel

Znaki wodne

pdf.ApplyWatermark("<h2 style='color:red;'>CONFIDENTIAL</h2>");
pdf.ApplyWatermark("<h2 style='color:red;'>CONFIDENTIAL</h2>");
pdf.ApplyWatermark("<h2 style='color:red;'>CONFIDENTIAL</h2>")
$vbLabelText   $csharpLabel

Ochrona hasłem

pdf.SecuritySettings.UserPassword = "userpassword";
pdf.SecuritySettings.OwnerPassword = "ownerpassword";
pdf.SecuritySettings.UserPassword = "userpassword";
pdf.SecuritySettings.OwnerPassword = "ownerpassword";
pdf.SecuritySettings.UserPassword = "userpassword"
pdf.SecuritySettings.OwnerPassword = "ownerpassword"
$vbLabelText   $csharpLabel

Wyodrębnianie tekstu

string text = pdf.ExtractAllText();
string text = pdf.ExtractAllText();
Dim text As String = pdf.ExtractAllText()
$vbLabelText   $csharpLabel

Przebieg pracy "Generuj, a następnie PRINT"

Dzięki IronPDF możesz generować pliki PDF i drukować je w ramach jednego procesu:

var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Invoice</h1>");
pdf.Print("Invoice Printer");
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Invoice</h1>");
pdf.Print("Invoice Printer");
Dim renderer As New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf("<h1>Invoice</h1>")
pdf.Print("Invoice Printer")
$vbLabelText   $csharpLabel

Drukowanie wielopłatformowe

PDFPrinting.NET działa wyłącznie w systemie Windows.IronPDF działa na wielu platformach:

Windows

pdf.Print("HP LaserJet");
pdf.Print("HP LaserJet");
pdf.Print("HP LaserJet")
$vbLabelText   $csharpLabel

Linux

// Requires CUPS (Common Unix Printing System)
// Install: apt-get install cups
pdf.Print("HP_LaserJet");  // CUPS uses underscores instead of spaces
// Requires CUPS (Common Unix Printing System)
// Install: apt-get install cups
pdf.Print("HP_LaserJet");  // CUPS uses underscores instead of spaces
$vbLabelText   $csharpLabel

macOS

pdf.Print("HP LaserJet");
pdf.Print("HP LaserJet");
pdf.Print("HP LaserJet")
$vbLabelText   $csharpLabel

Podsumowanie porównania funkcji

Funkcja PDFPrinting.NET IronPDF
Ciche drukowanie
Ustawienia drukowania
HTML do PDF
URL do pliku PDF
Nagłówki/stopki Podstawowe Pełny kod HTML
Łączenie plików PDF
Podział plików PDF
Znaki wodne
Ekstrakcja tekstu
Ochrona hasłem
Wielopłatformowe

Lista kontrolna migracji

Przed migracją

  • Sporządź spis wszystkich miejsc użycia PDFPrinting.NET w kodzie źródłowym
  • Udokumentuj wszystkie obecnie używane nazwy drukarek
  • Zwróć uwagę na wszystkie konfiguracje ustawień drukowania
  • Sprawdź, czy potrzebna jest obsługa wielu platform
  • Zaplanuj przechowywanie klucza licencyjnego IronPDF(zalecane są zmienne środowiskowe)
  • Najpierw przetestuj z Licencją Trial IronPDF

Zmiany w pakiecie

  • Usuń pakiet NuGet PdfPrintingNet
  • Zainstaluj pakiet NuGet IronPdf: dotnet add package IronPdf

Zmiany w kodzie

  • Zaktualizuj importy przestrzeni nazw (PdfPrintingNet / przestarzały TerminalWorks.PDFPrintingIronPdf)
  • Przekształć wywołania pdfPrint.Print(path)na wzorzec PdfDocument.FromFile(path).Print()
  • Przenieś właściwości na potrzeby druku (Copies, Duplex, Collate, PrinterName) do obiektu PrintSettings
  • Zastosuj nowe możliwości: użyj ChromePdfRenderer.RenderHtmlAsPdf / RenderUrlAsPdf dla wejść HTML i URL (brak odpowiednika w PDFPrinting.NET)
  • Konfiguruj nagłówki/stopki poprzez RenderingOptions.HtmlHeader i HtmlFooter (nowa funkcjonalność)
  • Ustaw IronPdf.License.LicenseKey podczas startu aplikacji

Po migracji

  • Wykonaj druk próbny na wszystkich platformach docelowych
  • Sprawdź renderowanie nagłówków/stopek
  • Rozważ dodanie funkcji generowania plików PDF dla dokumentów dynamicznych
  • W razie potrzeby dodaj nowe funkcje (scałanie, znaki wodne, zabezpieczenia)

Zwróć uwagęPDFPrinting.NET jest zarejestrowanym znakiem towarowym swojego właściciela. Ta strona nie jest powiązana, polecana ani sponsorowana przez TerminalWorks. Wszystkie nazwy produktów, logo i marki są własnością ich odpowiednich właścicieli. Porównania mają charakter wyłącznie informacyjny i odzwierciedlają informacje dostępne publicznie w momencie pisania.

Curtis Chau
Autor tekstów technicznych

Curtis Chau posiada tytuł licencjata z informatyki (Uniwersytet Carleton) i specjalizuje się w front-endowym rozwoju, z ekspertką w Node.js, TypeScript, JavaScript i React. Pasjonuje się tworzeniem intuicyjnych i estetycznie przyjemnych interfejsów użytkownika, Curtis cieszy się pracą z nowoczesnymi frameworkami i tworzeniem dobrze zorganizowanych, atrakcyjnych wizualnie podrę...

Czytaj więcej

Zespół wsparcia Iron

Jesteśmy online 24 godziny, 5 dni w tygodniu.
Czat
E-mail
Zadzwoń do mnie