Lyo.Pdf.Rendering 1.0.2

dotnet add package Lyo.Pdf.Rendering --version 1.0.2
                    
NuGet\Install-Package Lyo.Pdf.Rendering -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Lyo.Pdf.Rendering" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Lyo.Pdf.Rendering" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Lyo.Pdf.Rendering" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Lyo.Pdf.Rendering --version 1.0.2
                    
#r "nuget: Lyo.Pdf.Rendering, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Lyo.Pdf.Rendering@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Lyo.Pdf.Rendering&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Lyo.Pdf.Rendering&version=1.0.2
                    
Install as a Cake Tool

Lyo.Pdf.Rendering

Rasterizes PDF pages to PNG via PDFtoImage (PDFium + Skia under the hood; bblanchon.PDFium native packages). Targets net10.0.

Examples

Usage

services.AddPdfPageRasterizer();

public sealed class CoverRenderer(IPdfPageRasterizer rasterizer)
{
    public async Task<byte[]> RenderAsync(ReadOnlyMemory<byte> pdf, CancellationToken ct)
        => (await rasterizer.RenderPageToPngAsync(pdf, pageNumber1Based: 1, dpi: 144, cancellationToken: ct))
            .ValueOrThrow()
            .PngBytes;
}

API

public interface IPdfPageRasterizer
{
    Task<Result<PdfRasterPage>> RenderPageToPngAsync(
        ReadOnlyMemory<byte> pdfBytes,
        int pageNumber1Based,
        int dpi,
        string? password = null,
        CancellationToken cancellationToken = default);
}

public sealed record PdfRasterPage(byte[] PngBytes, int WidthPx, int HeightPx);

API

PdfToImagePageRasterizer is the default implementation: it dispatches the CPU-bound PDFium call through Task.Run, probes the rendered bytes with ImageSharp to read the bitmap dimensions, and logs an elapsed-ms trace on success. Failures surface as Result<PdfRasterPage>.Failure tagged with:

  • PdfRenderErrorCodes.PageOutOfRange ("PDF_RENDER_PAGE_OUT_OF_RANGE") when pageNumber1Based > pageCount.
  • PdfRenderErrorCodes.RenderFailed ("PDF_RENDER_FAILED") for invalid PDFs, missing/incorrect passwords, or any PDFium error.

Usage

Pass the document password argument when the PDF is protected. Pages are 1-based. Prefer Lyo.Pdf.Ocr when you need to combine rasterization with IOcrEngine and project bounding boxes back into PDF coordinates.

Dependencies

Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).

  • Lyo.Common — (direct, lyo)
  • Lyo.Exceptions — (direct, lyo)
  • Lyo.Result — (direct, lyo)
  • Microsoft.Extensions.DependencyInjection.Abstractions 10.0.5 — (direct, microsoft)
  • Microsoft.Extensions.Logging.Abstractions 10.0.5 — (direct, microsoft)
  • PDFtoImage 5.2.1 — (direct, third-party)
  • SixLabors.ImageSharp 3.1.12 — (direct, third-party)
  • System.Memory 4.6.3 — (transitive, microsoft, netstandard2.0)
  • System.Text.Json 10.0.5 — (transitive, microsoft, netstandard2.0)
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Lyo.Pdf.Rendering:

Package Downloads
Lyo.Pdf.Ocr

OCR pipeline for PDF pages: rasterize (PDFium), run IOcrEngine, map pixel boxes to PDF points.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 0 8/19/2026
1.0.1 28 8/18/2026
1.0.0 58 8/16/2026