Zum Fußzeileninhalt springen
VIDEOS

Wie man den virtuellen Viewport und Zoom in C# verwendet

Der Wechsel von PDFFilePrintzu IronPDF verschiebt Ihren .NET-PDF-Workflow von einem ausschließlich zum Drucken verwendeten Pdfium Wrapper zu einer umfassenden PDF-Bibliothek, die Erstellung, Manipulation und Drucken in einer einheitlichen API behandelt. Dieser Leitfaden bietet einen schrittweisen Migrationspfad, der app.config-gestützte Druckeinstellungen durch stark typisierte PrinterSettings ersetzt und dabei PDF-Erstellungs- und -Manipulationsmöglichkeiten hinzufügt, die PDFFilePrintnicht bietet.

Warum von PDFFilePrintzu IronPDF migrieren

PDFFilePrintverständlich machen

PDFFilePrint ist ein kleines Open-Source-NuGet-Paket (MIT, von Christian Andersen), das PdfiumViewer und Googles Pdfium einbindet, um eine vorhandene PDF- oder XPS-Datei still an einen Druckertreiber zu senden. Die neueste Version ist 1.0.3, veröffentlicht am 2020-02-10, zielend auf .NET Framework 4.6.1+ auf Windows. Auch wenn es für gezielte Druckaufgaben nützlich ist, ist seine Funktionalität auf einen Aspekt der Dokumentenverarbeitung beschränkt – die öffentliche Oberfläche wird im Wesentlichen durch new FilePrint(path, null).Print() gesteuert, angetrieben durch app.config / Properties.Settings.Default-Schlüssel.

Kritische Einschränkungen von PDFFilePrint

  1. Nur-Druck: Kann keine PDFs erstellen, bearbeiten, zusammenführen oder ändern — die FilePrint-Klasse verarbeitet bestehende PDF/XPS-Dateien und übergibt sie an den Spooler.

  2. An Konfigurationsdatei-gebundene API: Druckername, Papierformat, Kopienzahl und 'Drucken auf Datei'-Modus werden aus app.config (Properties.Settings.Default) gelesen und nicht als stark typisiertes Optionsobjekt übergeben.

  3. Nur Windows + .NET Framework: Zielt auf net461 ab und zieht die Win32-nativen Binärdateien von PdfiumViewer ein. Keine .NET Core / .NET 6+ TFM und keine Unterstützung für Linux/macOS.

  4. Eingeschränkte Druckknöpfe: Duplex, Bereichsauswahl, Ausrichtung und Farbe basieren auf den Standardeinstellungen des Druckertreibers - es gibt keine hochwertige API dafür.

  5. Praktisch ungewartet: Keine Veröffentlichung seit 1.0.3 (Februar 2020) und kein öffentliches Quell-Repository, das von der NuGet-Liste verlinkt ist.

  6. Einfacher Ausnahmebereich: Fehler kommen von PdfiumViewer / dem Spooler als generische Ausnahmen an die Oberfläche, anstatt einer typisierten Fehlerhierarchie.

  7. Keine PDF-Erstellung: Kann keine PDFs erstellen - um von HTML, einer URL oder Bildern zu einer gedruckten Seite zu gelangen, müssen Sie PDFFilePrintmit einem separaten Renderer koppeln.

PDFFilePrintvs IronPDF Vergleich

Aspekt PDFFilePrint IronPDF
Primärer Schwerpunkt PDF/XPS-Drucken Umfassende PDF-API
Typ Pdfium Druckwrapper Native .NET-Bibliothek + Chromium-Renderer
Integration new FilePrint(...).Print() + app.config Direkte PdfDocument API
PDF-Druck Ja Ja
PDF-Erstellung Nein Ja (HTML, URL, Bilder)
PDF-Bearbeitung Nein Ja (zusammenführen, auftrennen, bearbeiten)
Plattformübergreifend Nur Windows (net461) Windows, Linux, macOS, Docker
Fehlerbehandlung Einfachen Ausnahmen von PdfiumViewer Typisierte IronPdfException
IntelliSense Minimal (kleine Oberfläche) Voll
NuGet-Paket PDFFilePrint 1.0.3 (MIT, Feb 2020) IronPdf
Letzte Veröffentlichung 1.0.3 (Februar 2020) Aktive Veröffentlichungen

Für Teams, die moderne .NET (Framework 4.6.2+ und .NET 6/7/8/9/10) anvisieren, bietet IronPDF eine umfassende Grundlage mit plattformübergreifender Unterstützung und aktiver Entwicklung, die PDFFilePrints architektonische Einschränkungen adressiert.


Bevor Sie beginnen

Voraussetzungen

  1. .NET Environment: .NET Framework 4.6.2+ or .NET 6/7/8/9/10
  2. NuGet -Zugriff: Möglichkeit zur Installation von NuGet -Paketen
  3. IronPDF -Lizenz: Ihren Lizenzschlüssel erhalten Sie unter IronPDF.

NuGet-Paketänderungen

# Remove PDFFilePrintpackage
dotnet remove package PDFFilePrint

# Install IronPDF
dotnet add package IronPdf
# Remove PDFFilePrintpackage
dotnet remove package PDFFilePrint

# Install IronPDF
dotnet add package IronPdf
SHELL

Lizenz-Konfiguration

// 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

PDFFilePrint-Verwendung identifizieren

# Find PDFFilePrintAPI usages
grep -r "using PDFFilePrint\|new FilePrint" --include="*.cs" .

# Find related app.config keys
grep -r "PrinterName\|PaperName\|PrintToFile\|DefaultPrintToDirectory" \
    --include="*.config" --include="*.settings" .
# Find PDFFilePrintAPI usages
grep -r "using PDFFilePrint\|new FilePrint" --include="*.cs" .

# Find related app.config keys
grep -r "PrinterName\|PaperName\|PrintToFile\|DefaultPrintToDirectory" \
    --include="*.config" --include="*.settings" .
SHELL

Komplette API-Referenz

Namensraumänderungen

// PDFFilePrint
using PDFFilePrint;

//IronPDF— printing flows through System.Drawing.Printing
using IronPdf;
using System.Drawing.Printing;
// PDFFilePrint
using PDFFilePrint;

//IronPDF— printing flows through System.Drawing.Printing
using IronPdf;
using System.Drawing.Printing;
Imports PDFFilePrint
Imports IronPdf
Imports System.Drawing.Printing
$vbLabelText   $csharpLabel

Kernklassen-Zuordnungen

PDFFilePrint IronPDF
new FilePrint(path, null) (lade) PdfDocument.FromFile(path)
new ChromePdfRenderer() (keine Entsprechung — PDFFilePrintkann keine PDFs erstellen) new ChromePdfRenderer()
FilePrint PdfDocument

PDF-Erzeugungsmethoden-Zuordnungen

PDFFilePrint IronPDF
(nicht verfügbar) renderer.RenderHtmlAsPdf(html)
(nicht verfügbar) renderer.RenderUrlAsPdf(url)
(nicht verfügbar - nur-drucken) pdf.SaveAs(path)

PDF Laden und Drucken von Zuordnungen

PDFFilePrint IronPDF
new FilePrint(path, null) PdfDocument.FromFile(path)
fileprint.Print() (stumm, immer) pdf.Print() (stumm) / pdf.Print(true) (Dialog)
Properties.Settings.Default.PrinterName = "..." dann Print() pdf.GetPrintDocument(new PrinterSettings { PrinterName = "..." }).Print()

Druckeinstellungen-Zuordnung (app.config zu PrinterSettings)

PDFFilePrint-Einstellung (Settings.Default) IronPDF(System.Drawing.Printing.PrinterSettings)
PrinterName PrinterName
Copies Copies
(kein stilles Flag - immer still) pdf.Print() (stumm) / pdf.Print(true) (Dialog anzeigen)
(Treiberstandard) FromPage, ToPage, PrintRange
(Treiberstandard) DefaultPageSettings.Landscape
(Treiberstandard) Duplex
(Treiberstandard) Collate
PaperName DefaultPageSettings.PaperSize
PrintToFile + DefaultPrintToDirectory PrintToFile + PrintFileName

Neue Funktionen nicht in PDFFilePrint

IronPDF Merkmal Beschreibung
PdfDocument.Merge() Kombinieren mehrerer PDFs
pdf.CopyPages() Spezifische Seiten extrahieren
pdf.ApplyWatermark() Wasserzeichen hinzufügen
pdf.SecuritySettings Passwortschutz
pdf.ExtractAllText() Textinhalt extrahieren
pdf.RasterizeToImageFiles() In Bilder konvertieren
pdf.SignWithDigitalSignature() Digitale Signaturen

Beispiele für die Code-Migration

Beispiel 1: Konvertierung von HTML in PDF

Vor (PDFFilePrint):

// NuGet: Install-Package PDFFilePrint
// PDFFilePrintis a print-only wrapper around PdfiumViewer / Pdfium.
// Its FilePrint class only consumes existing PDF/XPS files — there is
// no CreateFromHtml or document-creation method.
using System;

class Program
{
    static void Main()
    {
        throw new NotSupportedException(
            "PDFFilePrint cannot convert HTML to PDF. Render the HTML to a PDF " +
            "with another library, then pass the path to new FilePrint(path, null).Print().");
    }
}
// NuGet: Install-Package PDFFilePrint
// PDFFilePrintis a print-only wrapper around PdfiumViewer / Pdfium.
// Its FilePrint class only consumes existing PDF/XPS files — there is
// no CreateFromHtml or document-creation method.
using System;

class Program
{
    static void Main()
    {
        throw new NotSupportedException(
            "PDFFilePrint cannot convert HTML to PDF. Render the HTML to a PDF " +
            "with another library, then pass the path to new FilePrint(path, null).Print().");
    }
}
Imports System

Class Program
    Shared Sub Main()
        Throw New NotSupportedException("PDFFilePrint cannot convert HTML to PDF. Render the HTML to a PDF " & _
                                        "with another library, then pass the path to new FilePrint(path, null).Print().")
    End Sub
End Class
$vbLabelText   $csharpLabel

Nach (IronPDF):

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

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        string htmlContent = "<html><body><h1>Hello World</h1></body></html>";
        var pdf = renderer.RenderHtmlAsPdf(htmlContent);
        pdf.SaveAs("output.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        string htmlContent = "<html><body><h1>Hello World</h1></body></html>";
        var pdf = renderer.RenderHtmlAsPdf(htmlContent);
        pdf.SaveAs("output.pdf");
    }
}
Imports IronPdf
Imports System

Class Program
    Shared Sub Main()
        Dim renderer = New ChromePdfRenderer()
        Dim htmlContent As String = "<html><body><h1>Hello World</h1></body></html>"
        Dim pdf = renderer.RenderHtmlAsPdf(htmlContent)
        pdf.SaveAs("output.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

Der grundlegende Unterschied hier ist der Umfang. PDFFilePrinthat keine HTML-zu-PDF-Pfad — seine öffentliche Oberfläche ist eine FilePrint-Klasse, die ein bestehendes PDF an den Drucker übergibt.IronPDF trennt die Darstellung vom Dokumentenobjekt: ChromePdfRenderer kümmert sich um die HTML-zu-PDF-Konvertierung und gibt ein PdfDocument zurück, das Sie dann mit SaveAs() speichern.

Diese Trennung ermöglicht es Ihnen auch, Darstellungsoptionen am Renderer vor der Konvertierung zu konfigurieren und das zurückgegebene PdfDocument (Wasserzeichen hinzufügen, mit anderen PDFs zusammenführen, Sicherheit hinzufügen) vor dem Speichern zu manipulieren. Weitere Rendering-Optionen finden Sie in der HTML to PDF Dokumentation.

Beispiel 2: Konvertierung von URL in PDF

Vor (PDFFilePrint):

// NuGet: Install-Package PDFFilePrint
// PDFFilePrintcannot fetch a URL or render HTML — it only sends existing
// PDF/XPS files to a printer. URL-to-PDF requires a separate renderer.
using System;

class Program
{
    static void Main()
    {
        throw new NotSupportedException(
            "PDFFilePrint cannot convert URLs to PDF. Render the URL to a PDF with " +
            "another library first, then call new FilePrint(pdfPath, null).Print().");
    }
}
// NuGet: Install-Package PDFFilePrint
// PDFFilePrintcannot fetch a URL or render HTML — it only sends existing
// PDF/XPS files to a printer. URL-to-PDF requires a separate renderer.
using System;

class Program
{
    static void Main()
    {
        throw new NotSupportedException(
            "PDFFilePrint cannot convert URLs to PDF. Render the URL to a PDF with " +
            "another library first, then call new FilePrint(pdfPath, null).Print().");
    }
}
Imports System

Class Program
    Shared Sub Main()
        Throw New NotSupportedException("PDFFilePrint cannot convert URLs to PDF. Render the URL to a PDF with " & _
                                        "another library first, then call new FilePrint(pdfPath, null).Print().")
    End Sub
End Class
$vbLabelText   $csharpLabel

Nach (IronPDF):

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

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderUrlAsPdf("https://www.example.com");
        pdf.SaveAs("webpage.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderUrlAsPdf("https://www.example.com");
        pdf.SaveAs("webpage.pdf");
    }
}
Imports IronPdf
Imports System

Class Program
    Shared Sub Main()
        Dim renderer = New ChromePdfRenderer()
        Dim pdf = renderer.RenderUrlAsPdf("https://www.example.com")
        pdf.SaveAs("webpage.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

PDFFilePrint hat keine URL-Abruf-Funktion.IronPDF verwendet die spezielle RenderUrlAsPdf()-Methode auf ChromePdfRenderer, die eine Chromium-Engine für die Darstellung moderner CSS-, JavaScript- und Web-Features nutzt. Erfahren Sie mehr über die URL in PDF Konvertierung.

Beispiel 3: PDF-Druck

Vor (PDFFilePrint):

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

class Program
{
    static void Main()
    {
        // Optional: override the configured printer / copy count at runtime.
        Properties.Settings.Default.PrinterName = "Default Printer";

        var fileprint = new FilePrint("document.pdf", null);
        fileprint.Print();
        Console.WriteLine("PDF sent to printer");
    }
}
// NuGet: Install-Package PDFFilePrint
using System;
using PDFFilePrint;

class Program
{
    static void Main()
    {
        // Optional: override the configured printer / copy count at runtime.
        Properties.Settings.Default.PrinterName = "Default Printer";

        var fileprint = new FilePrint("document.pdf", null);
        fileprint.Print();
        Console.WriteLine("PDF sent to printer");
    }
}
Imports System
Imports PDFFilePrint

Module Program
    Sub Main()
        ' Optional: override the configured printer / copy count at runtime.
        Properties.Settings.[Default].PrinterName = "Default Printer"

        Dim fileprint = New FilePrint("document.pdf", Nothing)
        fileprint.Print()
        Console.WriteLine("PDF sent to printer")
    End Sub
End Module
$vbLabelText   $csharpLabel

Nach (IronPDF):

// NuGet: Install-Package IronPdf
using IronPdf;
using System;
using System.Drawing.Printing;

class Program
{
    static void Main()
    {
        var pdf = PdfDocument.FromFile("document.pdf");

        // Silent print to the default printer
        pdf.Print();

        // Or print to a named printer with explicit PrinterSettings:
        // var settings = new PrinterSettings { PrinterName = "HP LaserJet Pro" };
        // pdf.GetPrintDocument(settings).Print();

        Console.WriteLine("PDF sent to printer");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
using System.Drawing.Printing;

class Program
{
    static void Main()
    {
        var pdf = PdfDocument.FromFile("document.pdf");

        // Silent print to the default printer
        pdf.Print();

        // Or print to a named printer with explicit PrinterSettings:
        // var settings = new PrinterSettings { PrinterName = "HP LaserJet Pro" };
        // pdf.GetPrintDocument(settings).Print();

        Console.WriteLine("PDF sent to printer");
    }
}
Imports IronPdf
Imports System
Imports System.Drawing.Printing

Module Program
    Sub Main()
        Dim pdf = PdfDocument.FromFile("document.pdf")

        ' Silent print to the default printer
        pdf.Print()

        ' Or print to a named printer with explicit PrinterSettings:
        ' Dim settings As New PrinterSettings With {.PrinterName = "HP LaserJet Pro"}
        ' pdf.GetPrintDocument(settings).Print()

        Console.WriteLine("PDF sent to printer")
    End Sub
End Module
$vbLabelText   $csharpLabel

Dieses Beispiel zeigt den architektonischen Unterschied zwischen den beiden Bibliotheken. PDFFilePrintinstanziiert new FilePrint(path, null) und ruft Print() auf, wobei der Druckername und die Kopienzahl aus app.config (Properties.Settings.Default) gelesen werden.IronPDF verwendet die statische Fabrik PdfDocument.FromFile(), um zu laden, dann Print(), das den Standarddrucker verwendet — oder Sie übergeben eine System.Drawing.Printing.PrinterSettings über GetPrintDocument(settings).Print() für explizite Kontrolle.

Die wichtigsten Migrationsänderungen:

  • new FilePrint(path, null)PdfDocument.FromFile(path)
  • Properties.Settings.Default.PrinterName = "..." + Print()pdf.GetPrintDocument(new PrinterSettings { PrinterName = "..." }).Print()
  • Standarddrucker: lassen Sie PrinterName in Settings.Default leer → rufen Sie pdf.Print() auf

Für erweiterte Druckeinstellungen verwendet IronPDFSystem.Drawing.Printing.PrinterSettings. Siehe die Druckdokumentation für zusätzliche Optionen.


Erweiterte Migration der Druckeinstellungen

Für Anwendungen, die die app.config-Schlüssel von PDFFilePrintverwenden, ist hier, wie Sie zu den stark typisierten PrinterSettings von IronPDF migrieren können:

// PDFFilePrintapproach — settings live in app.config and are read via
// Properties.Settings.Default. To override at runtime you mutate Settings.Default
// before instantiating FilePrint:
//   Properties.Settings.Default.PrinterName = "HP LaserJet";
//   Properties.Settings.Default.Copies = 3;
//   new FilePrint("document.pdf", null).Print();
//
//IronPDF equivalent — pass a System.Drawing.Printing.PrinterSettings per call:
using IronPdf;
using System.Drawing.Printing;

var pdf = PdfDocument.FromFile("document.pdf");

var settings = new PrinterSettings
{
    PrinterName = "HP LaserJet",
    Copies = 3,
    FromPage = 1,
    ToPage = 5,
    PrintRange = PrintRange.SomePages
};

pdf.GetPrintDocument(settings).Print();
// PDFFilePrintapproach — settings live in app.config and are read via
// Properties.Settings.Default. To override at runtime you mutate Settings.Default
// before instantiating FilePrint:
//   Properties.Settings.Default.PrinterName = "HP LaserJet";
//   Properties.Settings.Default.Copies = 3;
//   new FilePrint("document.pdf", null).Print();
//
//IronPDF equivalent — pass a System.Drawing.Printing.PrinterSettings per call:
using IronPdf;
using System.Drawing.Printing;

var pdf = PdfDocument.FromFile("document.pdf");

var settings = new PrinterSettings
{
    PrinterName = "HP LaserJet",
    Copies = 3,
    FromPage = 1,
    ToPage = 5,
    PrintRange = PrintRange.SomePages
};

pdf.GetPrintDocument(settings).Print();
Imports IronPdf
Imports System.Drawing.Printing

' PDFFilePrintapproach — settings live in app.config and are read via
' Properties.Settings.Default. To override at runtime you mutate Settings.Default
' before instantiating FilePrint:
'   Properties.Settings.Default.PrinterName = "HP LaserJet"
'   Properties.Settings.Default.Copies = 3
'   new FilePrint("document.pdf", null).Print()
'
' IronPDF equivalent — pass a System.Drawing.Printing.PrinterSettings per call:

Dim pdf = PdfDocument.FromFile("document.pdf")

Dim settings As New PrinterSettings With {
    .PrinterName = "HP LaserJet",
    .Copies = 3,
    .FromPage = 1,
    .ToPage = 5,
    .PrintRange = PrintRange.SomePages
}

pdf.GetPrintDocument(settings).Print()
$vbLabelText   $csharpLabel

Stiller Modus

// PDFFilePrintis always silent — there is no print-dialog code path.
//IronPDF is silent by default. Pass true explicitly to show the print dialog:
pdf.Print();      // silent
pdf.Print(true);  // shows print dialog
// PDFFilePrintis always silent — there is no print-dialog code path.
//IronPDF is silent by default. Pass true explicitly to show the print dialog:
pdf.Print();      // silent
pdf.Print(true);  // shows print dialog
' PDFFilePrint is always silent — there is no print-dialog code path.
' IronPDF is silent by default. Pass True explicitly to show the print dialog:
pdf.Print()      ' silent
pdf.Print(True)  ' shows print dialog
$vbLabelText   $csharpLabel

Neue Funktionen nach der Migration

Nach der Umstellung auf IronPDF erhalten Sie Funktionen, die PDFFilePrintnicht bieten kann:

Erstellen und Drucken in einem Schritt

using IronPdf;
using System.Drawing.Printing;

var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Invoice #12345</h1><p>Thank you for your order.</p>");

var settings = new PrinterSettings { PrinterName = "Office Printer" };
pdf.GetPrintDocument(settings).Print();
using IronPdf;
using System.Drawing.Printing;

var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Invoice #12345</h1><p>Thank you for your order.</p>");

var settings = new PrinterSettings { PrinterName = "Office Printer" };
pdf.GetPrintDocument(settings).Print();
Imports IronPdf
Imports System.Drawing.Printing

Dim renderer As New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf("<h1>Invoice #12345</h1><p>Thank you for your order.</p>")

Dim settings As New PrinterSettings With {.PrinterName = "Office Printer"}
pdf.GetPrintDocument(settings).Print()
$vbLabelText   $csharpLabel

PDF-Zusammenführung

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

Wasserzeichen

var pdf = PdfDocument.FromFile("document.pdf");
pdf.ApplyWatermark("<h1 style='color:red; opacity:0.3;'>CONFIDENTIAL</h1>");
pdf.SaveAs("watermarked.pdf");
var pdf = PdfDocument.FromFile("document.pdf");
pdf.ApplyWatermark("<h1 style='color:red; opacity:0.3;'>CONFIDENTIAL</h1>");
pdf.SaveAs("watermarked.pdf");
Dim pdf = PdfDocument.FromFile("document.pdf")
pdf.ApplyWatermark("<h1 style='color:red; opacity:0.3;'>CONFIDENTIAL</h1>")
pdf.SaveAs("watermarked.pdf")
$vbLabelText   $csharpLabel

Passwortschutz

var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SecuritySettings.UserPassword = "userpassword";
pdf.SecuritySettings.OwnerPassword = "ownerpassword";
pdf.SaveAs("secured.pdf");
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SecuritySettings.UserPassword = "userpassword";
pdf.SecuritySettings.OwnerPassword = "ownerpassword";
pdf.SaveAs("secured.pdf");
Dim pdf = renderer.RenderHtmlAsPdf(html)
pdf.SecuritySettings.UserPassword = "userpassword"
pdf.SecuritySettings.OwnerPassword = "ownerpassword"
pdf.SaveAs("secured.pdf")
$vbLabelText   $csharpLabel

Textextraktion

var pdf = PdfDocument.FromFile("document.pdf");
string text = pdf.ExtractAllText();
var pdf = PdfDocument.FromFile("document.pdf");
string text = pdf.ExtractAllText();
Dim pdf = PdfDocument.FromFile("document.pdf")
Dim text As String = pdf.ExtractAllText()
$vbLabelText   $csharpLabel

Kritische Hinweise zur Migration

Klassenmuster-Änderung

PDFFilePrint verwendet eine kleine FilePrint-Klasse mit einer einzelnen Print()-Methode, gesteuert durch app.config.IronPDF trennt Rendering, Dokumentenmanipulation und Drucken in getrennte Typen:

// PDFFilePrint: load + silent print (settings come from app.config)
Properties.Settings.Default.PrinterName = "HP LaserJet";
var fileprint = new FilePrint(path, null);
fileprint.Print();

// IronPDF: PdfDocument for load/manipulate, PrinterSettings for print options
var pdf = PdfDocument.FromFile(path);
var settings = new PrinterSettings { PrinterName = "HP LaserJet" };
pdf.GetPrintDocument(settings).Print();

//IronPDF can also create PDFs from HTML — PDFFilePrintcannot
var renderer = new ChromePdfRenderer();
var newPdf = renderer.RenderHtmlAsPdf(html);
newPdf.SaveAs(path);
// PDFFilePrint: load + silent print (settings come from app.config)
Properties.Settings.Default.PrinterName = "HP LaserJet";
var fileprint = new FilePrint(path, null);
fileprint.Print();

// IronPDF: PdfDocument for load/manipulate, PrinterSettings for print options
var pdf = PdfDocument.FromFile(path);
var settings = new PrinterSettings { PrinterName = "HP LaserJet" };
pdf.GetPrintDocument(settings).Print();

//IronPDF can also create PDFs from HTML — PDFFilePrintcannot
var renderer = new ChromePdfRenderer();
var newPdf = renderer.RenderHtmlAsPdf(html);
newPdf.SaveAs(path);
' PDFFilePrint: load + silent print (settings come from app.config)
Properties.Settings.Default.PrinterName = "HP LaserJet"
Dim fileprint = New FilePrint(path, Nothing)
fileprint.Print()

' IronPDF: PdfDocument for load/manipulate, PrinterSettings for print options
Dim pdf = PdfDocument.FromFile(path)
Dim settings = New PrinterSettings With {.PrinterName = "HP LaserJet"}
pdf.GetPrintDocument(settings).Print()

' IronPDF can also create PDFs from HTML — PDFFilePrint cannot
Dim renderer = New ChromePdfRenderer()
Dim newPdf = renderer.RenderHtmlAsPdf(html)
newPdf.SaveAs(path)
$vbLabelText   $csharpLabel

Methode / Einstellung Namensänderungen

// PDFFilePrint→ IronPDF
new FilePrint(path, null)                       → PdfDocument.FromFile(path)
fileprint.Print()                               → pdf.Print()  // silent default
Properties.Settings.Default.PrinterName = "X"   → new PrinterSettings { PrinterName = "X" }
Properties.Settings.Default.Copies = 3          → new PrinterSettings { Copies = 3 }
Properties.Settings.Default.PaperName = "A4"    → settings.DefaultPageSettings.PaperSize = ...
// PDFFilePrinthas no native HTML/URL/merge/watermark methods — these are IronPDF-only.
// PDFFilePrint→ IronPDF
new FilePrint(path, null)                       → PdfDocument.FromFile(path)
fileprint.Print()                               → pdf.Print()  // silent default
Properties.Settings.Default.PrinterName = "X"   → new PrinterSettings { PrinterName = "X" }
Properties.Settings.Default.Copies = 3          → new PrinterSettings { Copies = 3 }
Properties.Settings.Default.PaperName = "A4"    → settings.DefaultPageSettings.PaperSize = ...
// PDFFilePrinthas no native HTML/URL/merge/watermark methods — these are IronPDF-only.
Imports IronPdf

Dim pdf As PdfDocument = PdfDocument.FromFile(path)
pdf.Print() ' silent default

Dim printerSettings As New PrinterSettings With {
    .PrinterName = "X",
    .Copies = 3
}

settings.DefaultPageSettings.PaperSize = ... ' Adjust as needed for PaperSize configuration

' Note: PDFFilePrint has no native HTML/URL/merge/watermark methods — these are IronPDF-only.
$vbLabelText   $csharpLabel

Fehlerbehandlung

// PDFFilePrint: failures bubble up from PdfiumViewer as plain exceptions
try {
    new FilePrint(path, null).Print();
}
catch (Exception ex) {
    //Neingranular error type — log the message and inner exception.
}

// IronPDF: typed exception hierarchy
try {
    pdf.Print();
}
catch (IronPdf.Exceptions.IronPdfException ex) {
    // Granular error details
}
// PDFFilePrint: failures bubble up from PdfiumViewer as plain exceptions
try {
    new FilePrint(path, null).Print();
}
catch (Exception ex) {
    //Neingranular error type — log the message and inner exception.
}

// IronPDF: typed exception hierarchy
try {
    pdf.Print();
}
catch (IronPdf.Exceptions.IronPdfException ex) {
    // Granular error details
}
Imports IronPdf.Exceptions

' PDFFilePrint: failures bubble up from PdfiumViewer as plain exceptions
Try
    Dim filePrint As New FilePrint(path, Nothing)
    filePrint.Print()
Catch ex As Exception
    ' Neingranular error type — log the message and inner exception.
End Try

' IronPDF: typed exception hierarchy
Try
    pdf.Print()
Catch ex As IronPdfException
    ' Granular error details
End Try
$vbLabelText   $csharpLabel

Kein externes ausführbares Programm auf beiden Wegen

Beide Bibliotheken werden als NuGet-Pakete geliefert. Es gibt kein PDFFilePrint.exe zu bündeln oder zu entfernen — dotnet remove package PDFFilePrint genügt auf der Seite von PDFFilePrint.IronPDF ist ähnlich eigenständig durch das IronPdf-Paket, wobei native Abhängigkeiten zur Wiederherstellungszeit gelöst werden.


Zusammenfassung des Funktionsvergleichs

Feature PDFFilePrint IronPDF
Grundlegendes Drucken
Stummes Drucken ✓ (immer still)
Mehrere Kopien ✓ (über app.config)
Umfang der Seite Nur Treiberstandard
Duplex Nur Treiberstandard
Aus HTML erstellen
Von URL erstellen
PDFs zusammenführen
PDFs teilen
Wasserzeichen hinzufügen
Text extrahieren
Passwortschutz
Digitale Signaturen
Plattformübergreifend ✗ (Windows / net461)
Native .NET-API ✓ (kleine Oberfläche)

Migrations-Checkliste

Vor der Migration

  • Finden Sie alle using PDFFilePrint; und new FilePrint(...) Aufrufstellen
  • Dokumentieren Sie aktuelle app.config-Einstellungen (PrinterName, PaperName, Copies, PrintToFile, DefaultPrintToDirectory)
  • Identifizieren Sie die in den verschiedenen Umgebungen verwendeten Druckernamen.
  • Beachten Sie jeden Code, der Properties.Settings.Default zur Laufzeit verändert
  • Identifizieren Sie Möglichkeiten für neue Funktionen (HTML/URL-Rendering, Zusammenführen, Wasserzeichen, Sicherheit) -IronPDF-Lizenzschlüssel erhalten

Paketänderungen

  • Entfernen Sie das PDFFilePrint-NuGet-Paket: dotnet remove package PDFFilePrint
  • Installieren Sie das IronPdf-NuGet-Paket: dotnet add package IronPdf
  • Ersetzen Sie using PDFFilePrint; durch using IronPdf; (fügen Sie bei Bedarf using System.Drawing.Printing; hinzu)

Code-Änderungen

  • Lizenzschlüsselkonfiguration beim Start hinzufügen
  • Ersetzen Sie new FilePrint(path, null) durch PdfDocument.FromFile(path)
  • Bewegen Sie Drucker-/Kopien-/Papier-Einstellungen aus app.config und in System.Drawing.Printing.PrinterSettings
  • Verwenden Sie pdf.Print() für lautlosen Standarddrucker-Ausgabe, oder pdf.GetPrintDocument(settings).Print() für explizite Optionen
  • Verpacken Sie Print()-Aufrufe in try / catch IronPdfException, wo Sie zuvor generische Ausnahmen abgefangen haben
  • Für HTML/URL/zusammenführen/Wasserzeichen-Funktionen (die PDFFilePrintnie angeboten hat), verwenden Sie ChromePdfRenderer und die PdfDocument-Manipulations-API

Nach der Migration

  • Entfernen Sie PDFFilePrint-spezifische Schlüssel aus app.config
  • Testdruck auf allen Zieldruckern
  • Testen Sie plattformübergreifend, falls zutreffend (Linux-Druck erfordert CUPS)
  • Fügen Sie neue Funktionen hinzu (Wasserzeichen, Sicherheit, Zusammenführung), falls erforderlich
  • Dokumentation aktualisieren

Hinweis:PDFFilePrint ist ein eingetragenes Markenzeichen seines jeweiligen Eigentümers. Diese Seite ist nicht mit PDFFilePrintverbunden, genehmigt oder gesponsert. Alle Produktnamen, Logos und Marken sind Eigentum ihrer jeweiligen Eigentümer. Vergleiche dienen nur zu Informationszwecken und spiegeln öffentlich zugängliche Informationen zum Zeitpunkt des Schreibens wider.

Curtis Chau
Technischer Autor

Curtis Chau hat einen Bachelor-Abschluss in Informatik von der Carleton University und ist spezialisiert auf Frontend-Entwicklung mit Expertise in Node.js, TypeScript, JavaScript und React. Leidenschaftlich widmet er sich der Erstellung intuitiver und ästhetisch ansprechender Benutzerschnittstellen und arbeitet gerne mit modernen Frameworks sowie der Erstellung gut strukturierter, optisch ansprechender ...

Weiterlesen

Iron-Support-Team

Wir sind 24 Stunden am Tag, 5 Tage die Woche online.
Chat
E-Mail
Rufen Sie mich an