Getting Started with IronPrint

This article was translated from English: Does it need improvement?
Translated
View the article in English

IronPrint : Votre bibliothèque d'impression tout-en-un pour .NET

IronPrint est une bibliothèque d'impression développée par Iron Software. La bibliothèque est compatible avec une grande variété d'environnements, notamment Windows, macOS, Android et iOS.

Compatibilité

IronPrint a une compatibilité de support multiplateforme avec :

Prise en charge de la version .NET

  • C#, VB.NET, F#
  • <.NET 8, 7, 6, 5 et Core 3.1+
  • .NET Framework (4.6.2+)

Systèmes d'exploitation et environnements

  • Windows (7+, Server 2016+)
  • macOS (10+)
  • iOS (11+)
  • Android API 21+ (v5 "Lollipop")

Prise en charge des types de projets .NET

  • Mobile (Xamarin & MAUI & Avalonia)
  • Desktop (WPF & MAUI & Windows Avalonia)
  • Console (App & Library)

Installation

Bibliothèque IronPrint

Installez le package IronPrint via le gestionnaire de packages NuGet :

dotnet add package IronPrint

Vous pouvez également télécharger directement à partir du site officiel NuGet d'IronPrint.

Une fois installé, vous pouvez commencer par ajouter utilisant IronPrint; en haut de votre code C#.

Application de la clé de licence

Ensuite, appliquez une licence ou une clé d'essai valide à IronPrint en affectant la clé de licence à la propriété LicenseKey de la classe License. Incluez le code suivant juste après l'instruction d'importation, avant d'utiliser toute méthode IronPrint :

using IronPrint;

// Apply your IronPrint license key here
License.LicenseKey = "your-license-key-here";
using IronPrint;

// Apply your IronPrint license key here
License.LicenseKey = "your-license-key-here";
Imports IronPrint

' Apply your IronPrint license key here
License.LicenseKey = "your-license-key-here"
$vbLabelText   $csharpLabel

Exemples de code

Document imprimé

Il suffit de transmettre le chemin d'accès au fichier à la méthode Print pour imprimer le document.

using IronPrint;

class Program
{
    static void Main()
    {
        // Specify the file path to be printed
        string filePath = "document.pdf";

        // Invoke the Print method to print the document
        IronPrint.Print(filePath);
    }
}
using IronPrint;

class Program
{
    static void Main()
    {
        // Specify the file path to be printed
        string filePath = "document.pdf";

        // Invoke the Print method to print the document
        IronPrint.Print(filePath);
    }
}
Imports IronPrint

Friend Class Program
	Shared Sub Main()
		' Specify the file path to be printed
		Dim filePath As String = "document.pdf"

		' Invoke the Print method to print the document
		IronPrint.Print(filePath)
	End Sub
End Class
$vbLabelText   $csharpLabel

Imprimer avec le dialogue

Utilisez la méthode ShowPrintDialog pour imprimer le document, qui affiche également la boîte de dialogue d'impression avant l'impression.

using IronPrint;

class Program
{
    static void Main()
    {
        // Specify the file path to be printed
        string filePath = "document.pdf";

        // Invoke the ShowPrintDialog method to prompt the dialog before printing
        IronPrint.ShowPrintDialog(filePath);
    }
}
using IronPrint;

class Program
{
    static void Main()
    {
        // Specify the file path to be printed
        string filePath = "document.pdf";

        // Invoke the ShowPrintDialog method to prompt the dialog before printing
        IronPrint.ShowPrintDialog(filePath);
    }
}
Imports IronPrint

Friend Class Program
	Shared Sub Main()
		' Specify the file path to be printed
		Dim filePath As String = "document.pdf"

		' Invoke the ShowPrintDialog method to prompt the dialog before printing
		IronPrint.ShowPrintDialog(filePath)
	End Sub
End Class
$vbLabelText   $csharpLabel

Personnaliser les paramètres d'impression

Pour configurer les paramètres d'impression à partir du code, instanciez la classe PrintSettings. Configurez l'objet PrintSettings et transmettez-le à l'une des méthodes d'impression.

using IronPrint;

class Program
{
    static void Main()
    {
        // Create a PrintSettings object to configure printer settings
        PrintSettings settings = new PrintSettings
        {
            Copies = 2,
            Duplex = DuplexMode.Vertical,
            PageOrientation = PageOrientation.Landscape
        };

        // Specify the file path to be printed
        string filePath = "document.pdf";

        // Invoke the Print method with custom print settings
        IronPrint.Print(filePath, settings);
    }
}
using IronPrint;

class Program
{
    static void Main()
    {
        // Create a PrintSettings object to configure printer settings
        PrintSettings settings = new PrintSettings
        {
            Copies = 2,
            Duplex = DuplexMode.Vertical,
            PageOrientation = PageOrientation.Landscape
        };

        // Specify the file path to be printed
        string filePath = "document.pdf";

        // Invoke the Print method with custom print settings
        IronPrint.Print(filePath, settings);
    }
}
Imports IronPrint

Friend Class Program
	Shared Sub Main()
		' Create a PrintSettings object to configure printer settings
		Dim settings As New PrintSettings With {
			.Copies = 2,
			.Duplex = DuplexMode.Vertical,
			.PageOrientation = PageOrientation.Landscape
		}

		' Specify the file path to be printed
		Dim filePath As String = "document.pdf"

		' Invoke the Print method with custom print settings
		IronPrint.Print(filePath, settings)
	End Sub
End Class
$vbLabelText   $csharpLabel

Licences et assistance disponibles

IronPrint est une bibliothèque payante, cependant, des licences d'essai gratuites sont également disponibles ici.

Pour plus d'informations sur Iron Software, veuillez consulter notre site web : https://ironsoftware.com/ Pour plus d'assistance et de demandes, veuillez demander à notre équipe.

Support d'Iron Software

Pour toute demande d'assistance générale ou technique, veuillez nous envoyer un courrier électronique à l'adresse suivante support@ironsoftware.com.

Curtis Chau
Rédacteur technique

Curtis Chau détient un baccalauréat en informatique (Université de Carleton) et se spécialise dans le développement front-end avec expertise en Node.js, TypeScript, JavaScript et React. Passionné par la création d'interfaces utilisateur intuitives et esthétiquement plaisantes, Curtis aime travailler avec des frameworks modernes ...

Lire la suite
Prêt à commencer?
Nuget Téléchargements 34,016 | Version : 2025.11 vient de sortir