### View Prewarm Initialization Logs Source: https://github.com/boletonet/boletonetcore/blob/master/BoletoNetCore.Playwright.Extensions/README.md Example log output when PrewarmOnStart is enabled. ```text info: BoletoNetCore.PlaywrightRendererHostedService Initializing Playwright renderer... info: BoletoNetCore.PlaywrightRendererHostedService Playwright renderer initialized successfully in 487ms ``` -------------------------------- ### Install the NuGet package Source: https://github.com/boletonet/boletonetcore/blob/master/BoletoNetCore.Playwright.Extensions/README.md Use the dotnet CLI to add the package to your project. ```bash dotnet add package BoletoNetCore.Playwright.Extensions ``` -------------------------------- ### Install Playwright Chromium Source: https://github.com/boletonet/boletonetcore/blob/master/BoletoNetCore.Playwright.ConsoleApp/README.md Commands to build the project and install the required Chromium browser for Playwright. ```bash dotnet build -o ./build pwsh ./build/playwright.ps1 install chromium ``` ```bash dotnet build -c Release -o ./build pwsh ./build/playwright.ps1 install chromium ``` -------------------------------- ### Install BoletoNetCore.Playwright via CLI Source: https://github.com/boletonet/boletonetcore/blob/master/BoletoNetCore.Playwright/README.md Commands to add the package, build the project, and install the required Chromium browser. ```bash # Instalar o pacote dotnet add package BoletoNetCore.Playwright # Compilar o projeto (gera o script de instalação) dotnet build -o ./build # Instalar o Chromium pwsh ./build/playwright.ps1 install chromium ``` -------------------------------- ### Configure Output Formats in C# Source: https://github.com/boletonet/boletonetcore/blob/master/BoletoNetCore.Playwright/README.md Examples of initializing PdfFormat, PngFormat, and JpegFormat with custom settings. ```csharp // PDF com margens customizadas var pdf = new PdfFormat( PaperFormat: "A4", Margin: new PdfMargins { Top = "5mm", Bottom = "5mm", Left = "10mm", Right = "10mm" } ); // PNG com viewport específico var png = new PngFormat(ViewportWidth: 800, ViewportHeight: 600); // JPEG com qualidade alta var jpeg = new JpegFormat(Quality: 95); ``` -------------------------------- ### Render Boletos Directly Source: https://github.com/boletonet/boletonetcore/blob/master/BoletoNetCore.Playwright/README.md Examples of rendering boletos to PDF, PNG, and JPEG formats using the RenderPlaywright method. ```csharp // PDF byte[] pdf = boleto.RenderPlaywright(PdfFormat.Default); // PNG byte[] png = boleto.RenderPlaywright(PngFormat.Default); // JPEG com qualidade customizada byte[] jpeg = boleto.RenderPlaywright(new JpegFormat(Quality: 90)); // Múltiplos boletos em um único PDF byte[] pdfLote = boletos.RenderPlaywright(PdfFormat.Default); ``` -------------------------------- ### Instalar dependências de PDF no Linux Source: https://github.com/boletonet/boletonetcore/blob/master/README.md Comando necessário para instalar as bibliotecas de sistema exigidas para a geração de PDFs em ambientes baseados em Debian. ```bash apt-get install -y libfontconfig1 libxrender1 libxext6 ``` -------------------------------- ### Run Performance Benchmark Source: https://github.com/boletonet/boletonetcore/blob/master/BoletoNetCore.Playwright/README.md Command to execute the performance benchmark for PDF generation using the console application. ```bash cd BoletoNetCore.Playwright.ConsoleApp dotnet run -c Release -- metrics --output ./results --total 100 --concurrency 4 ``` -------------------------------- ### Configurar permissões do binário wkhtmltopdf Source: https://github.com/boletonet/boletonetcore/blob/master/README.md Comando para conceder permissão de execução ao binário do wkhtmltopdf utilizado para a geração de documentos PDF. ```bash chmod +x "/BoletoNetCore.Testes/bin/Debug/net7.0/Rotativa/Linux/wkhtmltopdf" ``` -------------------------------- ### Comparação de Geração de Arquivo Remessa Source: https://github.com/boletonet/boletonetcore/blob/master/migracao.md Exemplos comparativos da implementação da classe ArquivoRemessa entre a versão antiga e a nova versão do BoletoNetCore. ```csharp var rem = new ArquivoRemessa(TipoArquivo.CNAB240); MemoryStream ms = new MemoryStream(); rem.GerarArquivoRemessa(numeroConvenio, new Banco(codBanco), cedente, _boletos, ms, numeroArqRemessa); retBoletos.ArquivoRemessa = Encoding.Default.GetString(ms.ToArray()); ``` ```csharp var rem = new ArquivoRemessa(_banco, TipoArquivo.CNAB240, 1); //<== IMPLEMENTAR AQUI NUMERO SEQUENCIAL DO ARQ REMESSA!!! MemoryStream ms = new MemoryStream(); rem.GerarArquivoRemessa(boletos, ms); retBoletos.ArquivoRemessa = Encoding.Default.GetString(ms.ToArray()); //< ``` -------------------------------- ### Generate Boletos with Simple Command Source: https://github.com/boletonet/boletonetcore/blob/master/BoletoNetCore.Playwright.ConsoleApp/README.md Usage of the simple command to generate boletos in PDF, PNG, or JPEG formats. ```bash dotnet run -c Release -- simple -o [opcoes] ``` ```bash # PDF com 4 boletos dotnet run -c Release -- simple -o D:\temp # PNG com margem de 30px dotnet run -c Release -- simple -o D:\temp -f png -m 30 # JPEG com qualidade 90 e 10 boletos dotnet run -c Release -- simple -o D:\temp -f jpeg -q 90 -c 10 ``` -------------------------------- ### Implement Boleto Rendering Service Source: https://github.com/boletonet/boletonetcore/blob/master/BoletoNetCore.Playwright.Extensions/README.md Inject IHtmlRenderer to generate PDF or PNG outputs from Boleto objects. ```csharp public class BoletoService { private readonly IHtmlRenderer _renderer; public BoletoService(IHtmlRenderer renderer) { _renderer = renderer; } public async Task GerarPdfAsync(Boleto boleto, CancellationToken ct = default) { return await boleto.RenderPlaywrightAsync(_renderer, PdfFormat.Default, cancellationToken: ct); } public async Task GerarPngAsync(Boleto boleto, CancellationToken ct = default) { return await boleto.RenderPlaywrightAsync(_renderer, PngFormat.Default, cancellationToken: ct); } public async Task GerarLotePdfAsync(Boletos boletos, CancellationToken ct = default) { return await boletos.RenderPlaywrightAsync(_renderer, PdfFormat.Default, cancellationToken: ct); } } ``` -------------------------------- ### Run Metrics Benchmark Source: https://github.com/boletonet/boletonetcore/blob/master/BoletoNetCore.Playwright.ConsoleApp/README.md Usage of the metrics command to benchmark PDF generation performance. ```bash dotnet run -c Release -- metrics -o [opcoes] ``` ```bash # Benchmark padrão: 100 PDFs com 4 threads dotnet run -c Release -- metrics -o D:\temp # 200 PDFs com 8 threads concorrentes dotnet run -c Release -- metrics -o D:\temp -t 200 -c 8 # Salvar os PDFs gerados dotnet run -c Release -- metrics -o D:\temp --save-pdfs ``` -------------------------------- ### Configure Dependency Injection Source: https://github.com/boletonet/boletonetcore/blob/master/BoletoNetCore.Playwright/README.md Registration of the Playwright renderer service in Program.cs with custom options. ```csharp // Program.cs services.AddPlaywrightRenderer(options => { options.MaxConcurrency = 4; options.PrewarmOnStart = true; }); ``` -------------------------------- ### Configure Playwright Renderer via Delegate Source: https://github.com/boletonet/boletonetcore/blob/master/BoletoNetCore.Playwright.Extensions/README.md Configure rendering options directly during service registration. ```csharp services.AddPlaywrightRenderer(options => { options.MaxConcurrency = 4; options.RenderTimeout = TimeSpan.FromSeconds(30); options.PrewarmOnStart = true; options.RestartOnFailure = true; }); ``` -------------------------------- ### Configure Playwright Renderer via appsettings.json Source: https://github.com/boletonet/boletonetcore/blob/master/BoletoNetCore.Playwright.Extensions/README.md Bind configuration from appsettings.json to the PlaywrightRendererOptions class. ```csharp // Program.cs builder.Services.AddPlaywrightRenderer(); builder.Services.Configure( builder.Configuration.GetSection("PlaywrightRenderer")); ``` ```json // appsettings.json { "PlaywrightRenderer": { "MaxConcurrency": 4, "RenderTimeoutSeconds": 30, "PrewarmOnStart": true, "RestartOnFailure": true } } ``` -------------------------------- ### Image Format Configuration Source: https://github.com/boletonet/boletonetcore/blob/master/BoletoNetCore.Playwright/README.md Configures image output formats including PNG and JPEG with specific viewport and quality settings. ```APIDOC ## PngFormat / JpegFormat ### Description Defines configuration for image-based output formats. ### Parameters - **ViewportWidth** (int) - Optional - Width of the viewport for rendering. - **ViewportHeight** (int) - Optional - Height of the viewport for rendering. - **Quality** (int) - Optional - Quality percentage for JPEG compression (0-100). ``` -------------------------------- ### Register Playwright Renderer Source: https://github.com/boletonet/boletonetcore/blob/master/BoletoNetCore.Playwright.Extensions/README.md Register the renderer service in your Program.cs file. ```csharp // Program.cs services.AddPlaywrightRenderer(); ``` -------------------------------- ### PdfFormat Configuration Source: https://github.com/boletonet/boletonetcore/blob/master/BoletoNetCore.Playwright/README.md Configures the PDF output format with options for paper size, orientation, margins, and CSS scaling. ```APIDOC ## PdfFormat ### Description Defines the configuration for generating PDF documents from boletos. ### Parameters - **PaperFormat** (string) - Optional - Paper size (e.g., "A4", "Letter", "Legal"). Default: "A4". - **Landscape** (bool) - Optional - Sets orientation to landscape. Default: false. - **PrintBackground** (bool) - Optional - Includes CSS backgrounds. Default: true. - **Scale** (float) - Optional - Scaling factor (0.1 to 2.0). Default: 1.0. - **Margin** (PdfMargins) - Optional - Page margins. Default: 10mm. - **PreferCssPageSize** (bool) - Optional - Uses dimensions defined by @page CSS. Default: false. ``` -------------------------------- ### BoletoNetCore.Playwright Project Structure Source: https://github.com/boletonet/boletonetcore/blob/master/BoletoNetCore.Playwright/README.md Visual representation of the project directory and component hierarchy. ```text BoletoNetCore.Playwright ├── IHtmlRenderer # Interface principal para renderização multi-formato ├── PlaywrightHtmlRenderer # Implementação com gerenciamento de browser ├── OutputFormat # Discriminated union (PdfFormat, PngFormat, JpegFormat) ├── PlaywrightExtensions # Métodos de extensão para Boleto/Boletos └── Internal/ ├── BrowserManager # Ciclo de vida do Chromium com crash recovery └── HtmlUtilities # Combinação de HTML para múltiplos boletos ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.