開始使用IronPrint
IronPrint: 一站式 .NET 打印庫
IronPrint 是由 Iron Software 開發的打印庫。該庫兼容多種環境,包括 Windows、macOS、Android 和 iOS。
C# 列印庫
- 下載C#程式庫以列印文件
- 處理 PDF、PNG、HTML、TIFF、GIF、JPEG、IMAGE、BITMAP 格式
- 自訂列印設定
- 在列印前顯示對話框
- 免費探索該庫在 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 "Lollipop")
.NET 專案類型支援
- 行動應用 (Xamarin & MAUI & Avalonia)
- 桌面 (WPF 與 MAUI 與 Windows Avalonia)
- 控制台 (應用程序及庫)
安裝
IronPrint Library
安裝 IronPrint 非常快速且簡單,請這樣安裝這個套件:
Install-Package IronPrint
或者,直接從 官方 IronPrint NuGet 網站安裝完成後,您可以通過在 C# 代碼的開頭添加 using IronPrint;
來開始。
應用授權金鑰
接下來,通過將授權金鑰分配給 License 類別的 LicenseKey 屬性,來應用有效的授權或試用金鑰給 IronPrint。在 import 語句之後、使用任何 IronPrint 方法之前,包含以下代碼:
:path=/static-assets/print/content-code-examples/get-started/get-started-license.cs
IronPrint.License.LicenseKey = "IRONPRINT.MYLICENSE.KEY.1EF01";
IronPrint.License.LicenseKey = "IRONPRINT.MYLICENSE.KEY.1EF01"
程式碼範例
列印文件
只需將檔案路徑傳遞給 Print
方法即可列印文件。
:path=/static-assets/print/content-code-examples/get-started/get-started-1.cs
using IronPrint;
// Print the document
Printer.Print("newDoc.pdf");
Imports IronPrint
' Print the document
Printer.Print("newDoc.pdf")
打印對話框
使用 ShowPrintDialog
方法來打印文檔,這個方法在打印之前會顯示打印對話框。
:path=/static-assets/print/content-code-examples/get-started/get-started-2.cs
using IronPrint;
// Show print dialog
Printer.ShowPrintDialog("newDoc.pdf");
Imports IronPrint
' Show print dialog
Printer.ShowPrintDialog("newDoc.pdf")
自訂列印設定
要從程式碼配置列印設定,請實例化 PrintSettings 類別。配置 PrintSettings 物件並將其傳遞給其中一個列印方法。
:path=/static-assets/print/content-code-examples/get-started/get-started-3.cs
using IronPrint;
// Configure print setting
PrintSettings printSettings = new PrintSettings();
printSettings.Dpi = 150;
printSettings.NumberOfCopies = 2;
printSettings.PaperOrientation = PaperOrientation.Portrait;
// Print the document
Printer.Print("newDoc.pdf", printSettings);
Imports IronPrint
' Configure print setting
Private printSettings As New PrintSettings()
printSettings.Dpi = 150
printSettings.NumberOfCopies = 2
printSettings.PaperOrientation = PaperOrientation.Portrait
' Print the document
Printer.Print("newDoc.pdf", printSettings)
授權及支援
IronPrint 是一個付費的庫,但是也提供免費試用授權。 這裡有關 Iron Software 的更多資訊,請訪問我們的網站:https://ironsoftware.com/ 如需更多支持和查詢,請 請詢問我們的團隊.
Iron Software 支援
如有一般支援及技術問題,請發送電子郵件至:support@ironsoftware.com