C#으로 문서 인쇄하기: IronPrint 튜토리얼
IronPrint .NET C# 개발자가 애플리케이션에 인쇄 기능을 통합하는 데 도움을 주기 위해 설계된 강력한 인쇄 라이브러리입니다. IronPrint Windows, macOS, iOS 및 Android 플랫폼을 아우르는 폭넓은 호환성을 갖추고 있어 다양한 운영 체제에서 일관되고 안정적으로 작동합니다. 데스크톱 환경, Apple의 macOS 생태계 또는 iOS 및 Android와 같은 모바일 플랫폼용 애플리케이션을 개발하든 IronPrint 인쇄 기능 구현을 간소화하여 .NET C# 환경에서 모든 인쇄 요구 사항에 맞는 다재다능하고 사용자 친화적인 솔루션을 제공합니다.
빠른 시작: IronPrint 로 문서를 조용히 인쇄하기
단 한 줄의 코드로 바로 출력할 수 있습니다. 대화 상자도 없고, 복잡한 과정도 필요 없습니다. IronPrint.Printer.Print(...)를 사용하여 기본 또는 사용자 지정 설정을 사용하여 PDF나 이미지를 프린터로 바로 조용히 보낼 수 있습니다.
목차
- 문서 인쇄
- 인쇄 설정 적용
- 프린터 정보 가져오기
문서 인쇄
소리 없이 인쇄하기
인쇄 대화 상자를 표시하지 않고도 문서를 원활하게 인쇄할 수 있습니다. 인쇄 설정은 코드 내에서 직접 수행할 수 있습니다.
// Programmatically print a document without showing the print dialog.
// Define your print job and settings here as needed.
using System;
using IronPrint;
public class SilentPrint
{
public static void Main()
{
// Create a print document instance
var document = new PrintDocument("sample-document.pdf");
// Initialize a silent print job
var printJob = new PrintJob(document);
// Apply specific settings as necessary
// For example: set printer name, copies, etc.
// Execute the print job
printJob.PrintSilently();
}
}
// Programmatically print a document without showing the print dialog.
// Define your print job and settings here as needed.
using System;
using IronPrint;
public class SilentPrint
{
public static void Main()
{
// Create a print document instance
var document = new PrintDocument("sample-document.pdf");
// Initialize a silent print job
var printJob = new PrintJob(document);
// Apply specific settings as necessary
// For example: set printer name, copies, etc.
// Execute the print job
printJob.PrintSilently();
}
}
' Programmatically print a document without showing the print dialog.
' Define your print job and settings here as needed.
Imports System
Imports IronPrint
Public Class SilentPrint
Public Shared Sub Main()
' Create a print document instance
Dim document = New PrintDocument("sample-document.pdf")
' Initialize a silent print job
Dim printJob As New PrintJob(document)
' Apply specific settings as necessary
' For example: set printer name, copies, etc.
' Execute the print job
printJob.PrintSilently()
End Sub
End Class
대화 상자를 사용하여 인쇄
인쇄 설정 대화 상자가 나타나면 인쇄 프로세스를 시작하십시오. 이를 통해 사용자는 인쇄 옵션을 대화형으로 맞춤 설정할 수 있습니다.
// Start a print job with user interaction through the print dialog.
using System;
using IronPrint;
public class DialogPrint
{
public static void Main()
{
// Create a print document instance
var document = new PrintDocument("sample-document.pdf");
// Initialize a print job with dialog
var printJob = new PrintJob(document);
// Execute the print job with display of print options dialog
printJob.PrintWithDialog();
}
}
// Start a print job with user interaction through the print dialog.
using System;
using IronPrint;
public class DialogPrint
{
public static void Main()
{
// Create a print document instance
var document = new PrintDocument("sample-document.pdf");
// Initialize a print job with dialog
var printJob = new PrintJob(document);
// Execute the print job with display of print options dialog
printJob.PrintWithDialog();
}
}
' Start a print job with user interaction through the print dialog.
Imports System
Imports IronPrint
Public Class DialogPrint
Public Shared Sub Main()
' Create a print document instance
Dim document = New PrintDocument("sample-document.pdf")
' Initialize a print job with dialog
Dim printJob As New PrintJob(document)
' Execute the print job with display of print options dialog
printJob.PrintWithDialog()
End Sub
End Class
인쇄 설정 적용
특정 요구 사항을 충족하도록 인쇄 설정을 프로그램 방식으로 조정합니다. 이 섹션에서는 코드를 통해 인쇄 설정을 세밀하게 조정할 수 있는 기능을 제공합니다.
// Example code to apply custom print settings programmatically.
using System;
using IronPrint;
public class PrintSettingsExample
{
public static void Main()
{
// Create a print document instance
var document = new PrintDocument("sample-document.pdf");
// Create a print job
var printJob = new PrintJob(document);
// Set custom print settings like duplex, color mode, etc.
var settings = new PrintSettings
{
ColorMode = ColorMode.Color,
DuplexMode = DuplexMode.OneSided,
Copies = 2
};
// Apply settings to print job
printJob.ApplySettings(settings);
// Print the document
printJob.PrintSilently();
}
}
// Example code to apply custom print settings programmatically.
using System;
using IronPrint;
public class PrintSettingsExample
{
public static void Main()
{
// Create a print document instance
var document = new PrintDocument("sample-document.pdf");
// Create a print job
var printJob = new PrintJob(document);
// Set custom print settings like duplex, color mode, etc.
var settings = new PrintSettings
{
ColorMode = ColorMode.Color,
DuplexMode = DuplexMode.OneSided,
Copies = 2
};
// Apply settings to print job
printJob.ApplySettings(settings);
// Print the document
printJob.PrintSilently();
}
}
' Example code to apply custom print settings programmatically.
Imports System
Imports IronPrint
Public Class PrintSettingsExample
Public Shared Sub Main()
' Create a print document instance
Dim document = New PrintDocument("sample-document.pdf")
' Create a print job
Dim printJob As New PrintJob(document)
' Set custom print settings like duplex, color mode, etc.
Dim settings = New PrintSettings With {
.ColorMode = ColorMode.Color,
.DuplexMode = DuplexMode.OneSided,
.Copies = 2
}
' Apply settings to print job
printJob.ApplySettings(settings)
' Print the document
printJob.PrintSilently()
End Sub
End Class
프린터 정보 가져오기
프린터 이름 가져오기
사용 가능한 모든 프린터 목록을 확인하세요. 시스템에 설치된 프린터 이름을 검색하여 정보 제공 또는 애플리케이션에서 동적으로 프린터를 선택하는 데 사용할 수 있습니다.
// Retrieve and display a list of printer names available on the system.
using System;
using IronPrint;
public class PrinterInfo
{
public static void Main()
{
// Get an enumerable list of printer names
var printerNames = PrinterSettings.GetAvailablePrinters();
// Print each printer name to the console
Console.WriteLine("Available Printers:");
foreach (var name in printerNames)
{
Console.WriteLine(name);
}
}
}
// Retrieve and display a list of printer names available on the system.
using System;
using IronPrint;
public class PrinterInfo
{
public static void Main()
{
// Get an enumerable list of printer names
var printerNames = PrinterSettings.GetAvailablePrinters();
// Print each printer name to the console
Console.WriteLine("Available Printers:");
foreach (var name in printerNames)
{
Console.WriteLine(name);
}
}
}
' Retrieve and display a list of printer names available on the system.
Imports System
Imports IronPrint
Public Class PrinterInfo
Public Shared Sub Main()
' Get an enumerable list of printer names
Dim printerNames = PrinterSettings.GetAvailablePrinters()
' Print each printer name to the console
Console.WriteLine("Available Printers:")
For Each name In printerNames
Console.WriteLine(name)
Next name
End Sub
End Class
자주 묻는 질문
.NET C#에서 문서를 소리 없이 인쇄하려면 어떻게 해야 하나요?
PrintJob 인스턴스의 PrintSilently() 메서드를 사용하면 사용자 상호 작용 없이 인쇄 작업을 실행할 수 있습니다. 이를 통해 인쇄 대화 상자를 표시하지 않고도 문서를 프로그램 방식으로 인쇄할 수 있습니다.
.NET C#에서 인쇄 대화 상자를 사용하여 문서를 인쇄하는 과정은 무엇입니까?
PrintJob 인스턴스의 PrintWithDialog() 메서드를 사용하면 사용자 상호 작용을 통해 인쇄 작업을 시작할 수 있습니다. 이 메서드는 인쇄 설정 대화 상자를 표시하여 사용자가 인쇄하기 전에 옵션을 사용자 지정할 수 있도록 합니다.
.NET C#에서 프로그래밍 방식으로 사용자 지정 인쇄 설정을 적용하는 것이 가능할까요?
예, PrintSettings 객체를 생성하고 색상 모드, 양면 인쇄 모드, 복사 매수 등의 속성을 구성하여 사용자 지정 인쇄 설정을 프로그래밍 방식으로 적용할 수 있습니다. 이렇게 설정한 값은 PrintJob 인스턴스에 적용할 수 있습니다.
.NET C# 애플리케이션에서 사용 가능한 프린터 이름을 어떻게 가져올 수 있나요?
PrinterSettings.GetAvailablePrinters() 메서드를 사용하면 사용 가능한 프린터 이름을 가져올 수 있습니다. 이 메서드는 시스템에 설치된 프린터 목록을 제공하여 선택 또는 정보 제공 목적으로 활용할 수 있도록 합니다.
.NET C# 라이브러리를 사용하여 다양한 문서 형식을 인쇄할 수 있습니까?
네, 해당 라이브러리는 PDF, PNG, HTML, TIFF, GIF, JPEG, IMAGE, BITMAP 등 다양한 문서 형식을 지원하여 다채로운 문서 인쇄 옵션을 제공합니다.
.NET C# 라이브러리를 사용하여 문서를 인쇄할 때 지원되는 플랫폼은 무엇입니까?
이 라이브러리는 Windows, macOS, iOS 및 Android와 같은 다양한 플랫폼을 지원하여 이러한 운영 체제 전반에서 일관되고 안정적인 인쇄 기능을 보장합니다.
.NET C#에서 무음 인쇄는 대화 상자 기반 인쇄와 어떻게 다른가요?
무음 인쇄는 PrintSilently() 메서드를 사용하여 사용자 상호 작용 없이 프로그램을 통해 문서를 인쇄할 수 있도록 합니다. 대화 상자 기반 인쇄는 PrintWithDialog() 메서드를 통해 사용자가 인쇄 설정을 지정할 수 있도록 인쇄 대화 상자를 표시하는 방식입니다.

