IronPrint 入門指南
IronPrint:您的 .NET 一體化列印庫
IronPrint是由 Iron Software 開發的列印庫。 該庫與多種環境相容,包括 Windows、macOS、Android 和 iOS。
C# 打印庫
- 下載C#程式庫以列印文件
- 支援處理 PDF、PNG、HTML、TIFF、GIF、JPEG、IMAGE、點陣圖格式
- 自訂列印設定
- 列印前顯示對話框
- 在 C# 中免費探索該庫的功能
相容性
IronPrint具有跨平台相容性,支援以下平台:
.NET 版本支援
- C# 、 VB.NET 、 F#
- .NET 8、7、6、5和 Core 3.1+
- .NET Framework (4.6.2+)
作業系統和環境支援
- Windows (7+,Server 2016+)
- macOS (10+)
- iOS (11+)
- Android API 21+(v5「棒棒糖」)
.NET 專案類型支援
- 行動 (Xamarin & MAUI & Avalonia)
- 桌面 (WPF & MAUI & Windows Avalonia)
- 控制台 (應用程式 & 程式庫)
安裝
IronPrint 圖書館
透過 NuGet 套件管理器安裝 IronPrint 套件:
或者,直接從官方IronPrint NuGet網站下載。
一旦安裝完成,您可以在您的C#代碼頂部添加using IronPrint;開始使用。
應用許可證密鑰
接下來,將有效的授權或試用金鑰指定給License類的LicenseKey 屬性以套用到IronPrint。 在導入語句之後、使用任何 IronPrint 方法之前,先加入以下程式碼:
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"Imports IronPrint
' Apply your IronPrint license key here
License.LicenseKey = "your-license-key-here"程式碼範例
列印文件
只需將檔案路徑傳遞給Print方法即可列印文件。
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 ClassImports 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帶對話框的列印
使用ShowPrintDialog方法列印文件,此方法在列印前也會顯示列印對話框。
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 ClassImports 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自訂列印設定
要從程式碼中配置列印設置,請實例化PrintSettings類。 配置PrintSettings物件並將其傳遞給列印方法之一。
using IronPrint;
class Program
{
static void Main()
{
// Create a PrintSettings object to configure printer settings
PrintSettings settings = new PrintSettings
{
NumberOfCopies = 2,
PaperOrientation = PaperOrientation.Landscape
};
// Specify the file path to be printed
string filePath = "document.pdf";
// Invoke the Print method with custom print settings
Printer.Print(filePath, settings);
}
}using IronPrint;
class Program
{
static void Main()
{
// Create a PrintSettings object to configure printer settings
PrintSettings settings = new PrintSettings
{
NumberOfCopies = 2,
PaperOrientation = PaperOrientation.Landscape
};
// Specify the file path to be printed
string filePath = "document.pdf";
// Invoke the Print method with custom print settings
Printer.Print(filePath, settings);
}
}Imports IronPrint
Module Program
Sub Main()
' Create a PrintSettings object to configure printer settings
Dim settings As New PrintSettings With {
.NumberOfCopies = 2,
.PaperOrientation = PaperOrientation.Landscape
}
' Specify the file path to be printed
Dim filePath As String = "document.pdf"
' Invoke the Print method with custom print settings
Printer.Print(filePath, settings)
End Sub
End ModuleImports IronPrint
Module Program
Sub Main()
' Create a PrintSettings object to configure printer settings
Dim settings As New PrintSettings With {
.NumberOfCopies = 2,
.PaperOrientation = PaperOrientation.Landscape
}
' Specify the file path to be printed
Dim filePath As String = "document.pdf"
' Invoke the Print method with custom print settings
Printer.Print(filePath, settings)
End Sub
End Module提供許可和支援
IronPrint是一個付費的程式庫; 然而,免費試用授權也可以在這裡獲得。
如需更多關於Iron Software的信息,請訪問我們的網站:https://ironsoftware.com/ 如需更多支援和查詢,請諮詢我們的團隊。
Iron Software 提供的支援
如需一般支援和技術查詢,請發送電子郵件至:support@ironsoftware.com。
Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。