Primeiros passos com o IronPrint
IronPrint: Sua biblioteca de impressão completa para .NET
IronPrint é uma biblioteca de impressão desenvolvida pela Iron Software. A biblioteca é compatível com uma ampla variedade de ambientes, incluindo Windows, macOS, Android e iOS.
Biblioteca de impressão em C#
- Baixe a biblioteca C# para imprimir documentos.
- Suporta formatos PDF, PNG, HTML, TIFF, GIF, JPEG, IMAGE e BITMAP.
- Personalize as configurações de impressão
- Exibir diálogo antes de imprimir
- Explore gratuitamente os recursos da biblioteca em C#.
Compatibilidade
O IronPrint possui compatibilidade multiplataforma com:
Suporte à versão .NET
- C# , VB .NET , F#
- .NET 8, 7 , 6, 5 e Core 3.1+
- .NET Framework (4.6.2 ou superior)
Suporte a sistemas operacionais e ambientes
- Windows (7+, Servidor 2016+)
- macOS (10+)
- iOS (11+)
- Android API 21+ (v5 "Lollipop")
Suporte a tipos de projeto .NET
- Dispositivos móveis (Xamarin, Maui e Avalonia)
- Área de trabalho (WPF, MAUI e Windows Avalonia)
- Console (Aplicativo e Biblioteca)
Instalação
Biblioteca IronPrint
Instale o pacote IronPrint através do Gerenciador de Pacotes NuGet :
Alternativamente, faça o download diretamente do site oficial do IronPrint no NuGet .
Uma vez instalado, você pode começar adicionando using IronPrint; no topo do seu código C#.
Aplicando a chave de licença
Em seguida, aplique uma chave de licença válida ou de teste ao IronPrint atribuindo a chave de licença à propriedade LicenseKey da classe License. Inclua o seguinte código logo após a declaração de importação, antes de usar qualquer método do IronPrint :
using IronPrint;
// Apply your IronPrint license key here
License.LicenseKey = "your-license-key-here";Imports IronPrint
' Apply your IronPrint license key here
License.LicenseKey = "your-license-key-here"Imports IronPrint
' Apply your IronPrint license key here
License.LicenseKey = "your-license-key-here"Exemplos de código
Imprimir documento
Simplesmente passe o caminho do arquivo para o método Print para imprimir o documento.
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);
}
}Imports IronPrint
Friend Class Program
Shared Sub Main()
' Specify the file path to be printed
Dim filePath As String = "document.pdf"
' Invoke the Print method to print the document
IronPrint.Print(filePath)
End Sub
End ClassImports IronPrint
Friend Class Program
Shared Sub Main()
' Specify the file path to be printed
Dim filePath As String = "document.pdf"
' Invoke the Print method to print the document
IronPrint.Print(filePath)
End Sub
End ClassImprimir com caixa de diálogo
Use o método ShowPrintDialog para imprimir o documento, que também mostra o diálogo de impressão antes da impressão.
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);
}
}Imports IronPrint
Friend Class Program
Shared Sub Main()
' Specify the file path to be printed
Dim filePath As String = "document.pdf"
' Invoke the ShowPrintDialog method to prompt the dialog before printing
IronPrint.ShowPrintDialog(filePath)
End Sub
End ClassImports IronPrint
Friend Class Program
Shared Sub Main()
' Specify the file path to be printed
Dim filePath As String = "document.pdf"
' Invoke the ShowPrintDialog method to prompt the dialog before printing
IronPrint.ShowPrintDialog(filePath)
End Sub
End ClassPersonalizar configurações de impressão
Para configurar as configurações de impressão a partir do código, instancie a classe PrintSettings. Configure o objeto PrintSettings e passe-o para um dos métodos de impressão.
using IronPrint;
class Program
{
static void Main()
{
// Create a PrintSettings object to configure printer settings
PrintSettings settings = new PrintSettings
{
NumberOfCopies = 2,
PaperOrientation = PaperOrientation.Landscape
};
// Specify the file path to be printed
string filePath = "document.pdf";
// Invoke the Print method with custom print settings
Printer.Print(filePath, settings);
}
}using IronPrint;
class Program
{
static void Main()
{
// Create a PrintSettings object to configure printer settings
PrintSettings settings = new PrintSettings
{
NumberOfCopies = 2,
PaperOrientation = PaperOrientation.Landscape
};
// Specify the file path to be printed
string filePath = "document.pdf";
// Invoke the Print method with custom print settings
Printer.Print(filePath, settings);
}
}Imports IronPrint
Module Program
Sub Main()
' Create a PrintSettings object to configure printer settings
Dim settings As New PrintSettings With {
.NumberOfCopies = 2,
.PaperOrientation = PaperOrientation.Landscape
}
' Specify the file path to be printed
Dim filePath As String = "document.pdf"
' Invoke the Print method with custom print settings
Printer.Print(filePath, settings)
End Sub
End ModuleImports IronPrint
Module Program
Sub Main()
' Create a PrintSettings object to configure printer settings
Dim settings As New PrintSettings With {
.NumberOfCopies = 2,
.PaperOrientation = PaperOrientation.Landscape
}
' Specify the file path to be printed
Dim filePath As String = "document.pdf"
' Invoke the Print method with custom print settings
Printer.Print(filePath, settings)
End Sub
End ModuleLicenciamento e suporte disponíveis
IronPrint é uma biblioteca paga; no entanto, licenças de avaliação gratuitas também estão disponíveis aqui.
Para obter mais informações sobre a Iron Software, visite nosso site:https://ironsoftware.com/ Para obter mais suporte e esclarecer dúvidas, entre em contato com nossa equipe .
Suporte da Iron Software
Para suporte geral e dúvidas técnicas, envie um e-mail para:support@ironsoftware.com .
Curtis Chau é bacharel em Ciência da Computação (Universidade Carleton) e se especializa em desenvolvimento front-end, com experiência em Node.js, TypeScript, JavaScript e React. Apaixonado por criar interfaces de usuário intuitivas e esteticamente agradáveis, Curtis gosta de trabalhar com frameworks modernos e criar manuais bem estruturados e visualmente atraentes.