Premiers pas avec 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 est compatible avec plusieurs plateformes :

Prise en charge des versions .NET

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

Support des systèmes d'exploitation et des 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 et Avalonia)
  • Bureau (WPF, MAUI et Windows Avalonia)
  • Console (Applications et bibliothèque)

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 depuis le site Web officiel d'IronPrint NuGet .

Une fois installé, vous pouvez commencer en ajoutant using 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 attribuant la clé de licence à la propriété LicenseKey de la classe License . Insérez le code suivant juste après l'instruction d'importation, avant d'utiliser les méthodes 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

Imprimer le document

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 boîte de dialogue

Utilisez la méthode ShowPrintDialog pour imprimer le document ; celle-ci 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

Licence et support 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 pour toute question, veuillez contacter notre équipe .

Assistance d'Iron Software

Pour toute assistance générale et questions techniques, veuillez nous contacter par e-mail à 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,704 | Version: 2025.11 vient de sortir