# 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.
<div class="hsg-featured-snippet">
<h2>Biblioteca de impressão em C#</h2>
<ol>
<li><a href="https://www.nuget.org/packages/IronPrint/">Baixe a biblioteca C# para imprimir documentos.</a></li>
<li>Suporta formatos PDF, PNG, HTML, TIFF, GIF, JPEG, IMAGE e BITMAP.</li>
<li>Personalize as configurações de impressão</li>
<li>Exibir diálogo antes de imprimir</li>
<li>Explore gratuitamente os recursos da biblioteca em C#.</li>
</ol>
</div>
### 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 :
```shell
:InstallCmd dotnet add package IronPrint
```
Alternativamente, faça o download diretamente do [site oficial do IronPrint no NuGet](https://www.nuget.org/packages/IronPrint) .
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 :
```csharp
using 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.
```csharp
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);
}
}
```
### Imprimir 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.
```csharp
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);
}
}
```
### Personalizar 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.
```csharp
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);
}
}
```
## Licenciamento e suporte disponíveis
**IronPrint** é uma biblioteca paga; no entanto, licenças de avaliação gratuitas também estão disponíveis [aqui](trial-license).
Para obter mais informações sobre a Iron Software, visite nosso site:[https://ironsoftware.com/](https://ironsoftware.com/) Para obter mais suporte e esclarecer dúvidas, [entre em contato com nossa equipe](/contact-us/) .
### Suporte da Iron Software
Para suporte geral e dúvidas técnicas, envie um e-mail para:[support@ironsoftware.com](mailto:support@ironsoftware.com) .
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.
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 hereLicense.LicenseKey = "your-license-key-here";
using IronPrint;
// Apply your IronPrint license key here
License.LicenseKey = "your-license-key-here";
ImportsIronPrint' Apply your IronPrint license key hereLicense.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 voidMain() { // Specify the file path to be printed string filePath = "document.pdf"; // Invoke the Print method to print the documentIronPrint.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);
}
}
ImportsIronPrintFriend Class ProgramShared Sub Main() ' Specify the file path to be printed Dim filePath AsString = "document.pdf" ' Invoke the Print method to print the documentIronPrint.Print(filePath) End SubEnd Class
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 Class
Imprimir 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 voidMain() { // Specify the file path to be printed string filePath = "document.pdf"; // Invoke the ShowPrintDialog method to prompt the dialog before printingIronPrint.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);
}
}
ImportsIronPrintFriend Class ProgramShared Sub Main() ' Specify the file path to be printed Dim filePath AsString = "document.pdf" ' Invoke the ShowPrintDialog method to prompt the dialog before printingIronPrint.ShowPrintDialog(filePath) End SubEnd Class
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 Class
Personalizar 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 voidMain() { // 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 settingsIronPrint.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);
}
}
ImportsIronPrintFriend Class ProgramShared Sub Main() ' Create a PrintSettings object to configure printer settings Dim settings As New PrintSettingsWith { .Copies = 2, .Duplex = DuplexMode.Vertical, .PageOrientation = PageOrientation.Landscape } ' Specify the file path to be printed Dim filePath AsString = "document.pdf" ' Invoke the Print method with custom print settingsIronPrint.Print(filePath, settings) End SubEnd Class
Imports IronPrint
Friend Class Program
Shared Sub Main()
' Create a PrintSettings object to configure printer settings
Dim settings As New PrintSettings With {
.Copies = 2,
.Duplex = DuplexMode.Vertical,
.PageOrientation = PageOrientation.Landscape
}
' Specify the file path to be printed
Dim filePath As String = "document.pdf"
' Invoke the Print method with custom print settings
IronPrint.Print(filePath, settings)
End Sub
End Class
Licenciamento e suporte disponíveis
IronPrint é uma biblioteca paga; no entanto, licenças de avaliação gratuitas também estão disponíveis aqui.
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.