Comment utiliser le Viewport Virtuel et le Zoom en C#
La migration de PDFFilePrintvers IronPDF déplace votre flux de travail PDF .NET d'un wrapper Pdfium axé sur l'impression uniquement à une bibliothèque PDF complète qui gère la création, la manipulation et l'impression dans une seule API unifiée. Ce guide fournit un chemin de migration étape par étape qui remplace les paramètres d'impression app.config par des PrinterSettings fortement typées, tout en ajoutant des capacités de génération et de manipulation PDF que PDFFilePrintne fournit pas.
Pourquoi passer de PDFFilePrintà IronPDF
Comprendre PDFFilePrint
PDFFilePrint est un petit package NuGet open source (MIT, par Christian Andersen) qui encapsule PdfiumViewer et Pdfium de Google pour envoyer silencieusement un fichier PDF ou XPS existant à un pilote d'impression. La dernière version est 1.0.3, publiée le 2020-02-10, ciblant .NET Framework 4.6.1+ sur Windows. Bien qu'utile pour les tâches d'impression ciblées, sa fonctionnalité est limitée à un aspect de la gestion des documents — la surface publique est essentiellement new FilePrint(path, null).Print() pilotée par app.config / Properties.Settings.Default.
Limitations critiques de PDFFilePrint
-
Impression uniquement : Ne peut pas créer, éditer, fusionner ou modifier des PDFs — la classe
FilePrintconsomme les fichiers PDF/XPS existants et les remet au spouleur. -
API pilotée par un fichier de configuration : Le nom de l'imprimante, la taille du papier, le nombre de copies et le mode "imprimer vers fichier" sont lus à partir de
app.config(Properties.Settings.Default), et ne sont pas passés comme un objet d'options fortement typé. -
Windows + .NET Framework uniquement : Cible
net461et inclut les binaires natifs Win32 de PdfiumViewer. Pas de TFM for .NET Core / .NET 6+, et pas de support Linux/macOS. -
Commandes d'impression limitées : Le recto verso, la plage de pages, l'orientation et la couleur dépendent du paramètre par défaut du pilote d'impression — il n'y a pas d'API de premier ordre pour eux.
-
Effectivement non maintenu : Pas de publication depuis la version 1.0.3 (février 2020) et pas de dépôt source public lié depuis la liste NuGet.
-
Surface d'exception simple : Les échecs remontent de PdfiumViewer / le spooler comme des exceptions génériques plutôt que comme une hiérarchie d'erreurs typée.
- Pas de génération de PDF : Ne peut pas créer de PDF — pour passer de HTML, une URL ou des images à une page imprimée, vous devez associer PDFFilePrintà un moteur de rendu séparé.
Comparaison PDFFilePrintvs IronPDF
| Aspect | PDFFilePrint | IronPDF |
|---|---|---|
| Accent principal | Impression PDF/XPS | API PDF complète |
| Type | Wrapper d'impression Pdfium | Bibliothèque native .NET + moteur de rendu Chromium |
| Intégration | new FilePrint(...).Print() + app.config |
API PdfDocument directe |
| Imprimer au format PDF | Oui | Oui |
| Création de PDF | Non | Oui (HTML, URL, images) |
| Manipulation de PDF | Non | Oui (fusionner, diviser, éditer) |
| Cross-Platform | Windows uniquement (net461) | Windows, Linux, macOS, Docker |
| Gestion des erreurs | Exceptions simples de PdfiumViewer | IronPdfException typé |
| IntelliSense | Minimal (petite surface) | Complet |
| Paquet NuGet | PDFFilePrint 1.0.3 (MIT, février 2020) |
IronPdf |
| Dernière version | 1.0.3 (fév 2020) | Versions actives |
Pour les équipes ciblant .NET moderne (Framework 4.6.2+ et .NET 6/7/8/9/10),IronPDF offre une base complète avec support multiplateforme et développement actif, répondant aux limitations architecturales de PDFFilePrint.
Avant de commencer
Prérequis
- .NET Environment: .NET Framework 4.6.2+ or .NET 6/7/8/9/10
- Accès à NuGet : possibilité d'installer des packages NuGet
- Licence IronPDF : Obtenez votre clé de licence sur IronPDF
Modifications du paquet NuGet
# Remove PDFFilePrintpackage
dotnet remove package PDFFilePrint
# Install IronPDF
dotnet add package IronPdf
# Remove PDFFilePrintpackage
dotnet remove package PDFFilePrint
# Install IronPDF
dotnet add package IronPdf
Configuration de la licence
// 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"
Identifier l'utilisation de PDFFilePrint
# 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" .
Référence API complète
Modifications de l'espace de nommage
// 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
Mappages de classes de base
| PDFFilePrint | IronPDF |
|---|---|
new FilePrint(path, null) (chargement) |
PdfDocument.FromFile(path) |
new ChromePdfRenderer() (aucun équivalent — PDFFilePrintne peut pas créer des PDFs) |
new ChromePdfRenderer() |
FilePrint |
PdfDocument |
Mappages de méthodes de génération de PDF
| PDFFilePrint | IronPDF |
|---|---|
| (non disponible) | renderer.RenderHtmlAsPdf(html) |
| (non disponible) | renderer.RenderUrlAsPdf(url) |
| (non disponible — impression uniquement) | pdf.SaveAs(path) |
Mappages de chargement et d'impression de fichiers PDF
| PDFFilePrint | IronPDF |
|---|---|
new FilePrint(path, null) |
PdfDocument.FromFile(path) |
fileprint.Print() (silencieux, toujours) |
pdf.Print() (silencieux) / pdf.Print(true) (dialogue) |
Properties.Settings.Default.PrinterName = "..." puis Print() |
pdf.GetPrintDocument(new PrinterSettings { PrinterName = "..." }).Print() |
Mapping des paramètres d'impression (app.config à PrinterSettings)
Paramétrage PDFFilePrint(Settings.Default) |
IronPDF(System.Drawing.Printing.PrinterSettings) |
|---|---|
PrinterName |
PrinterName |
Copies |
Copies |
| (pas de drapeau silencieux — toujours silencieux) | pdf.Print() (silencieux) / pdf.Print(true) (afficher le dialogue) |
| (par défaut du pilote) | FromPage, ToPage, PrintRange |
| (par défaut du pilote) | DefaultPageSettings.Landscape |
| (par défaut du pilote) | Duplex |
| (par défaut du pilote) | Collate |
PaperName |
DefaultPageSettings.PaperSize |
PrintToFile + DefaultPrintToDirectory |
PrintToFile + PrintFileName |
Nouvelles fonctionnalités absentes de PDFFilePrint
| Fonctionnalité d'IronPDF | Description du projet |
|---|---|
PdfDocument.Merge() |
Combiner plusieurs PDF |
pdf.CopyPages() |
Extraire des pages spécifiques |
pdf.ApplyWatermark() |
Ajouter des filigranes |
pdf.SecuritySettings |
Protection par mot de passe |
pdf.ExtractAllText() |
Extraire le contenu du texte |
pdf.RasterizeToImageFiles() |
Convertir en images |
pdf.SignWithDigitalSignature() |
Signatures numériques |
Exemples de migration de code
Exemple 1 : Conversion HTML vers PDF
Avant (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
Après (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
La différence fondamentale ici est l'étendue. PDFFilePrintn'a pas de chemin HTML-vers-PDF — sa surface publique est une classe FilePrint qui remet un PDF existant à l'imprimante.IronPDF sépare le rendu de l'objet document : ChromePdfRenderer gère la conversion HTML-vers-PDF et renvoie un PdfDocument que vous enregistrez ensuite avec SaveAs().
Cette séparation vous permet également de configurer les options de rendu sur le moteur de rendu avant la conversion, et de manipuler le PdfDocument retourné (ajouter des filigranes, fusionner avec d'autres PDFs, ajouter de la sécurité) avant l'enregistrement. Voir la documentation HTML vers PDF pour des options de rendu supplémentaires.
Exemple 2 : Conversion d'une URL en PDF
Avant (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
Après (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
PDFFilePrint n'a pas de capacité de récupération d'URL.IronPDF utilise la méthode dédiée RenderUrlAsPdf() sur ChromePdfRenderer, qui s'appuie sur un moteur Chromium pour le rendu des CSS modernes, JavaScript et fonctionnalités web. En savoir plus sur la conversion d'URL en PDF.
Exemple 3 : Impression PDF
Avant (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
Après (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
Cet exemple montre la différence architecturale entre les deux bibliothèques. PDFFilePrintinstancie new FilePrint(path, null) et appelle Print(), avec le nom de l'imprimante et le nombre de copies lus à partir de app.config (Properties.Settings.Default).IronPDF utilise l'usine statique PdfDocument.FromFile() pour charger, puis Print() qui utilise l'imprimante par défaut — ou vous passez un System.Drawing.Printing.PrinterSettings via GetPrintDocument(settings).Print() pour un contrôle explicite.
Les principaux changements liés à la migration :
new FilePrint(path, null)→PdfDocument.FromFile(path)Properties.Settings.Default.PrinterName = "..."+Print()→pdf.GetPrintDocument(new PrinterSettings { PrinterName = "..." }).Print()- Imprimante par défaut : laissez
PrinterNamevide dansSettings.Default→ appelezpdf.Print()
Pour des paramètres d'impression avancés,IronPDF utilise System.Drawing.Printing.PrinterSettings. Voir la documentation d'impression pour des options supplémentaires.
Migration des paramètres d'impression avancés
Pour les applications utilisant les clés app.config de PDFFilePrint, voici comment migrer vers les PrinterSettings fortement typées d'IronPDF :
// 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()
Mode silencieux
// 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
Nouvelles capacités après la migration
Après avoir migré vers IronPDF, vous bénéficiez de fonctionnalités que PDFFilePrintne peut pas vous offrir :
Créer et imprimer en une seule étape
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()
Fusion de fichiers 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")
Marques de fond
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")
Protection par mot de passe
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")
Extraction de texte
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()
Notes de migration essentielles
Changement de modèle de classe
PDFFilePrint utilise une petite classe FilePrint avec une méthode unique Print(), pilotée par app.config.IronPDF sépare le rendu, la manipulation de documents, et l'impression en types distincts :
// 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)
Changements de nommage de méthode / paramètre
// 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.
Gestion des exceptions
// PDFFilePrint: failures bubble up from PdfiumViewer as plain exceptions
try {
new FilePrint(path, null).Print();
}
catch (Exception ex) {
// Non granular 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) {
// Non granular 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
Call New FilePrint(path, Nothing).Print()
Catch ex As Exception
' Non granular 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
Aucun exécutable externe de toute façon
Les deux bibliothèques sont fournies en tant que packages NuGet. Il n'y a pas de PDFFilePrint.exe à regrouper ou supprimer — dotnet remove package PDFFilePrint suffit du côté PDFFilePrint.IronPDF est de la même manière autonome via le paquet IronPdf, avec les dépendances natives résolues au moment de la restauration.
Résumé de la comparaison des fonctionnalités
| Fonction | PDFFilePrint | IronPDF |
|---|---|---|
| Impression de base | ✓ | ✓ |
| Impression silencieuse | ✓(toujours silencieux) | ✓ |
| Copies multiples | ✓ (via app.config) | ✓ |
| Gamme de pages | Par défaut du pilote uniquement | ✓ |
| Duplex | Par défaut du pilote uniquement | ✓ |
| Créer à partir de HTML | ✗ | ✓ |
| Créer à partir d'une URL | ✗ | ✓ |
| Fusionner des PDF | ✗ | ✓ |
| Diviser les PDF | ✗ | ✓ |
| Ajouter des filigranes | ✗ | ✓ |
| Extraire le texte | ✗ | ✓ |
| Protection par mot de passe | ✗ | ✓ |
| Signatures numériques | ✗ | ✓ |
| Multiplateforme | ✗ (Windows / net461) | ✓ |
| API native .NET | ✓(petite surface) | ✓ |
Liste de contrôle de la migration
Pré-migration
- Localisez tous les appels de
using PDFFilePrint;et les sites d'appel denew FilePrint(...) - Documentez les paramètres
app.configactuels (PrinterName,PaperName,Copies,PrintToFile,DefaultPrintToDirectory) - Identifier les noms d'imprimantes utilisés dans différents environnements
- Notez tout code qui modifie
Properties.Settings.Defaultà l'exécution - Identifiez les opportunités de nouvelles fonctionnalités (rendu HTML/URL, fusion, filigranes, sécurité)
- Obtenir une clé de licence IronPDF
Modifications du paquet
- Supprimez le paquet NuGet
PDFFilePrint:dotnet remove package PDFFilePrint - Installez le paquet NuGet
IronPdf:dotnet add package IronPdf - Remplacez
using PDFFilePrint;parusing IronPdf;(ajoutezusing System.Drawing.Printing;si nécessaire)
Modifications du code
- Ajouter la configuration de la clé de licence au démarrage
- Remplacez
new FilePrint(path, null)parPdfDocument.FromFile(path) - Déplacez les paramètres d'imprimante/copie/papier hors de
app.configet dansSystem.Drawing.Printing.PrinterSettings - Utilisez
pdf.Print()pour une sortie d'imprimante par défaut silencieuse, oupdf.GetPrintDocument(settings).Print()pour des options explicites - Enveloppez les appels
Print()danstry/catch IronPdfExceptionlà où vous attrapiez précédemment des exceptions génériques - Pour les fonctionnalités HTML/URL/fusion/filigrane (que PDFFilePrintn'offrait jamais), utilisez
ChromePdfRendereret l'API de manipulationPdfDocument
Après la migration
- Supprimez les clés spécifiques à PDFFilePrintde
app.config - Impression de test sur toutes les imprimantes cibles
- Testez la compatibilité multiplateforme si applicable (l'impression Linux nécessite CUPS)
- Ajoutez de nouvelles fonctionnalités (filigranes, sécurité, fusion) si nécessaire
- Mise à jour de la documentation

