在实际环境中测试
在生产中测试无水印。
随时随地为您服务。
打印PDF 文件在 .NET 中必须快速且可靠。 手动处理打印任务可能很繁琐,特别是当文档量很大时。 IronPrint一种.NET打印库,通过确保发票、报告和图像顺利打印且没有不必要的复杂性来消除这种麻烦。 这允许开发人员在不处理不可预测的打印机行为或耗时的配置的情况下自动化其打印工作流程。
企业依赖于发票、报告和运输标签的自动打印。 一些用户也由于业务原因希望打印特定页面。 手动打印引入了不必要的步骤和错误,减慢了工作流程。 通过集成IronPrint,开发人员可以消除这些低效,自动化重复任务,提高准确性。 这为需要及时且格式良好的文档的终端用户提供了更流畅的体验。
IronPrint 通过提供一种高效的方式来管理 PDF 和图像,从而简化了打印过程。 开发人员无需手动处理复杂的打印机设置,就能通过最少的设置将文档发送到打印机。这释放了更多时间以专注于核心应用程序功能,同时确保每次文档打印正确。下一步是在您的.NET项目中设置IronPrint。 这个过程很简单,一旦集成,它每次都能确保一致且可靠的打印。
安装IronPrint很简单。 将其添加到您的 .NET 项目的最简单方法是通过 NuGet 包管理器:
单击安装,让 Visual Studio 处理剩余的工作。
对于那些喜欢使用包管理器控制台的人,请使用以下命令:
Install-Package IronPrint
Install-Package IronPrint
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'Install-Package IronPrint
安装后,确保所有依赖项都已正确恢复。
安装后,IronPrint 只需进行最少的配置即可开始工作。 首先,确保您的应用程序可以访问所需的打印机驱动程序。 然后,通过引用库并设置基本参数来初始化IronPrint。 一个简单的实现可能如下所示:
using IronPrint;
Printer.Print("sample-document.pdf");
using IronPrint;
Printer.Print("sample-document.pdf");
Imports IronPrint
Printer.Print("sample-document.pdf")
此基本设置使应用程序能够立即将PDF文件发送到默认打印机。 开发人员可以通过指定不同的打印机、调整打印设置或根据需要集成其他配置来自定义行为。 完成安装和设置后,下一步是探索IronPrint的核心功能,以有效管理不同的打印场景。
IronPrint 使打印 PDF 和图像变得简单。 Print 方法高效处理 PDF 文件,直接发送到打印机,省去了不必要的步骤。 这在您需要快速高效地打印PDF文件时特别有用。 一个简单的实现看起来像这样:
using IronPrint;
Printer.Print("invoice.pdf");
using IronPrint;
Printer.Print("invoice.pdf");
Imports IronPrint
Printer.Print("invoice.pdf")
对于图像文件,IronPrint 支持 PNG、JPEG 和 BMP 等常见格式。Print 方法自动检测和处理图像,确保它们在打印时保持清晰度和分辨率。
using IronPrint;
Printer.Print("logo.png");
using IronPrint;
Printer.Print("logo.png");
Imports IronPrint
Printer.Print("logo.png")
单个文档中的多张图像按顺序处理。 IronPrint 确保格式保持不变,防止失真或质量损失。 这使其非常适合与PDF文件一起打印复杂报告或图形文档。
IronPrint 让开发人员能够控制文档的打印方式。 静默打印将PDF文档直接发送到打印机,无需用户输入。 这对于自动化批量打印的应用程序非常有用,可以减少中断并加快工作流程。 您也可以高效地打印多个PDF文件。
using IronPrint;
Printer.Print("report.pdf");
using IronPrint;
Printer.Print("report.pdf");
Imports IronPrint
Printer.Print("report.pdf")
或者,如果用户需要在打印之前调整设置,IronPrint 可以触发打印对话框。 这使用户可以选择打印机,设置页面方向,并在完成打印任务之前调整打印质量。
using IronPrint;
Printer.ShowPrintDialog("document.pdf");
using IronPrint;
Printer.ShowPrintDialog("document.pdf");
Imports IronPrint
Printer.ShowPrintDialog("document.pdf")
静默打印最适合不需要用户干预的自动化工作流程,而打印对话框则在需要自定义时是理想选择。 这两种方法确保了灵活性和效率,具体取决于应用程序的需求。 通过利用这些功能,开发人员可以在他们的.NET应用程序中集成自动化和用户友好的打印功能,从而确保顺利处理打印pdf文档。
使用IronPrint,开发人员可以自定义纸张大小和方向,以满足应用程序的需求。 这在使用非标准纸张格式打印或需要特定布局时特别有用。当前的打印文档对象允许开发人员高效管理这些配置。 要设置纸张大小和方向,只需初始化 PrintSettings 类并指定所需的属性:
using IronPrint;
PrintSettings printSettings = new PrintSettings
{
PaperSize = PaperSize.A4,
PaperOrientation = PaperOrientation.Landscape
};
Printer.Print("document.pdf", printSettings);
using IronPrint;
PrintSettings printSettings = new PrintSettings
{
PaperSize = PaperSize.A4,
PaperOrientation = PaperOrientation.Landscape
};
Printer.Print("document.pdf", printSettings);
Imports IronPrint
Private printSettings As New PrintSettings With {
.PaperSize = PaperSize.A4,
.PaperOrientation = PaperOrientation.Landscape
}
Printer.Print("document.pdf", printSettings)
为了更好地控制打印质量,开发人员可以调整DPI。(每英寸点数)设置以确保文件以正确的详细程度打印。 更高的DPI设置可以提高清晰度,但可能会增加打印时间。此外,您可以指定要打印的份数:
using IronPrint;
PrintSettings printSettings = new PrintSettings
{
Dpi = 300,
NumberOfCopies = 2
};
Printer.Print("report.pdf", printSettings);
using IronPrint;
PrintSettings printSettings = new PrintSettings
{
Dpi = 300,
NumberOfCopies = 2
};
Printer.Print("report.pdf", printSettings);
Imports IronPrint
Private printSettings As New PrintSettings With {
.Dpi = 300,
.NumberOfCopies = 2
}
Printer.Print("report.pdf", printSettings)
开发人员可以指定使用哪台打印机,而不是依赖系统的默认打印机。 这在有多台打印机可用的办公环境中特别有用:
using IronPrint;
PrintSettings printSettings = new PrintSettings
{
// Specified Printer name
PrinterName = "Your Printer Name"
};
// Input PDF file for PDF printing process
Printer.Print("invoice.pdf", printSettings);
using IronPrint;
PrintSettings printSettings = new PrintSettings
{
// Specified Printer name
PrinterName = "Your Printer Name"
};
// Input PDF file for PDF printing process
Printer.Print("invoice.pdf", printSettings);
Imports IronPrint
Private printSettings As New PrintSettings With {.PrinterName = "Your Printer Name"}
' Input PDF file for PDF printing process
Printer.Print("invoice.pdf", printSettings)
自定义边距有助于确保文档对齐正确,而灰度打印可以在不需要颜色时节省墨水。 边距以毫米为单位定义,以进行精确调整:
using IronPrint;
PrintSettings printSettings = new PrintSettings
{
PaperMargins = new Margins
{
Top = 10,
Right = 10,
Bottom = 10,
Left = 10
},
Grayscale = true
};
Printer.Print("draft.pdf", printSettings);
using IronPrint;
PrintSettings printSettings = new PrintSettings
{
PaperMargins = new Margins
{
Top = 10,
Right = 10,
Bottom = 10,
Left = 10
},
Grayscale = true
};
Printer.Print("draft.pdf", printSettings);
Imports IronPrint
Private printSettings As New PrintSettings With {
.PaperMargins = New Margins With {
.Top = 10,
.Right = 10,
.Bottom = 10,
.Left = 10
},
.Grayscale = True
}
Printer.Print("draft.pdf", printSettings)
通过利用这些高级打印设置,开发人员可以微调打印过程以满足一致且专业质量输出的特定要求。
IronPrint 允许开发人员检索系统上所有可用打印机的列表。 这在用户需要在开始打印任务之前选择特定打印机的应用程序中很有用。 GetPrinterNames 方法返回一个已安装打印机名称的数组。
using IronPrint;
var printers = Printer.GetPrinterNames();
foreach (var printer in printers)
{
Console.WriteLine(printer); // Outputs: OneNote (Desktop), Microsoft Print to PDF
}
using IronPrint;
var printers = Printer.GetPrinterNames();
foreach (var printer in printers)
{
Console.WriteLine(printer); // Outputs: OneNote (Desktop), Microsoft Print to PDF
}
Imports IronPrint
Private printers = Printer.GetPrinterNames()
For Each printer In printers
Console.WriteLine(printer) ' Outputs: OneNote (Desktop), Microsoft Print to PDF
Next printer
此实现获取可用的打印机名称并将其打印到控制台。 开发人员可以使用这些数据来填充下拉菜单或在其应用程序内动态分配打印机首选项。
IronPrint 通过提供一个强大而灵活的解决方案来处理 PDF 和图像,革新了 .NET 应用程序中的编程打印。 IronPrint 的高级打印设置为用户提供对纸张尺寸、打印质量、页边距和灰度选项的精确控制。 此外,其动态检索打印机信息的能力提高了可用性,使应用程序能够适应不同的环境而无需人工干预。
通过 IronPrint 高效准确地管理打印相关任务,开发人员可以专注于优化核心应用功能并提供无缝的功能体验。 IronPrint 提供了一个免费试用供开发人员在投入使用前探索其全部功能。 其许可起价为$749,为各种规模的企业提供具成本效益和可扩展的解决方案。