IronPrint 入門指南
IronPrint:您的 .NET 全方位列印程式庫
IronPrint 是由 Iron Software 開發的列印程式庫。 此函式庫相容於多種環境,包括 Windows、macOS、Android 及 iOS。
C# 列印函式庫
- 下載 C# 函式庫以列印文件
- 支援 PDF、PNG、HTML、TIFF、GIF、JPEG、IMAGE、BITMAP 格式
- 自訂列印設定
- PRINT前顯示對話方塊
- 免費探索 C# 版本的函式庫功能
相容性
IronPrint 支援以下平台的相容性:
.NET 版本支援
- C#、VB.NET、F#
- .NET 8、7、6、5 及 .NET Core 3.1+
- .NET Framework (4.6.2+)
支援的作業系統與環境
- Windows (7 以上版本、Server 2016 以上版本)
- macOS (10+)
- iOS (11+)
- Android API 21+ (v5 "Lollipop")
.NET 專案類型支援
- 行動裝置 (Xamarin、MAUI 及 Avalonia)
- 桌面端 (WPF、MAUI 及 Windows Avalonia)
- 控制台(應用程式與函式庫)
安裝
IronPrint程式庫
透過 NuGet 套件管理員安裝 IronPrint 套件:
dotnet add package IronPrint
您亦可直接從 IronPrint 官方 NuGet 網站下載。
安裝完成後,您只需在 C# 程式碼開頭加入 using IronPrint; 即可開始使用。
套用授權金鑰
接著,請將有效的授權金鑰或試用授權套用至 IronPrint,方法是將授權金鑰指派給 License 類別的 LicenseKey 屬性。 請在 import 語句之後、使用任何 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"
程式碼範例
列印文件
只需將檔案路徑傳遞給 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 Class
透過對話方塊列印
using 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 Class
自訂列印設定
若要透過程式碼設定 PRINT 選項,請建立 PrintSettings 類別的實例。 設定 PrintSettings 物件,並將其傳遞給其中一個 PRINT 方法。
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
提供授權與技術支援
IronPrint 是一款付費程式庫; 不過,您亦可在此取得免費試用授權。
如需更多關於 Iron Software 的資訊,請造訪我們的網站:https://ironsoftware.com/ 如需更多支援或有任何疑問,請聯繫我們的團隊。
Iron Software 提供支援
如需一般支援或技術諮詢,請透過電子郵件聯絡我們:support@ironsoftware.com。/support@ironsoftware.com

