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 包:
dotnet add package IronPrint
或者,直接从IronPrint NuGet 官方网站下载。
安装完成后,您可以通过在 C# 代码顶部添加using IronPrint;来开始使用。
应用许可证密钥
接下来,通过将许可证密钥分配给License类的LicenseKey属性,将有效的许可证密钥或试用密钥应用于 IronPrint。 在导入语句之后、使用任何 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";代码示例
打印文档
只需将文件路径传递给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);
}
}带对话框的打印
使用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);
}
}自定义打印设置
要通过代码配置打印设置,请实例化PrintSettings类。 配置PrintSettings对象并将其传递给其中一个打印方法。
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);
}
}可用的许可和支持
IronPrint是一个付费库,但是这里也提供免费试用许可证。
有关 Iron Software 的更多信息,请访问我们的网站:https://ironsoftware.com/如需更多帮助或有任何疑问,请联系我们的团队。
Iron Software 提供的支持
如需一般支持和技术咨询,请发送电子邮件至:support@ironsoftware.com 。






