列印文件教程
IronPrint 是一個強大的列印庫,旨在協助 .NET C# 開發者在其應用程式中整合列印功能。 IronPrint 在 Windows、macOS、iOS 和 Android 平台上具有廣泛的兼容性,可在不同操作系統上始終如一地穩定運作。 不論您是為桌面環境、Apple 的 macOS 生態系統或像 iOS 和 Android 這樣的移動平台創建應用程序,IronPrint 都能簡化打印功能的實施,為您在 .NET C# 環境中的所有打印需求提供多功能且用戶友好的解決方案。
快速開始使用IronPrint
立即在您的專案中使用IronPrint,並享受免費試用。
目錄
列印文件
靜默列印
無需顯示列印對話框即可無縫列印文件。 列印設置可以直接在程式碼中完成。
:path=/static-assets/print/content-code-examples/tutorials/print-document-print-silently.cs
using IronPrint;
// Print the document
Printer.Print("newDoc.pdf");
Imports IronPrint
' Print the document
Printer.Print("newDoc.pdf")
顯示列印對話框
使用列印設定對話框開始列印過程。 這允許用戶互動式地自定列印選項。
:path=/static-assets/print/content-code-examples/tutorials/print-document-print-with-dialog.cs
using IronPrint;
// Show print dialog
Printer.ShowPrintDialog("newDoc.pdf");
Imports IronPrint
' Show print dialog
Printer.ShowPrintDialog("newDoc.pdf")
套用列印設定
以程式設計方式調整打印設置以滿足特定需求。 此部分提供了通過代碼微調打印配置的功能。
:path=/static-assets/print/content-code-examples/tutorials/print-document-apply-print-setting.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)
獲取印表機資訊
取得打印機名稱
訪問所有可用打印機的列表。 检索系统上安装的打印机名称,用于信息目的或应用程序中的动态打印机选择。
:path=/static-assets/print/content-code-examples/tutorials/print-document-get-printer-names.cs
using IronPrint;
using System;
using System.Collections.Generic;
// Retrieve printers' name
List<string> printersName = Printer.GetPrinterNames();
foreach (var printer in printersName)
{
Console.WriteLine(printer);
}
Imports IronPrint
Imports System
Imports System.Collections.Generic
' Retrieve printers' name
Private printersName As List(Of String) = Printer.GetPrinterNames()
For Each printer In printersName
Console.WriteLine(printer)
Next printer