PdfForge.Avalonia 2.1.2

dotnet add package PdfForge.Avalonia --version 2.1.2
                    
NuGet\Install-Package PdfForge.Avalonia -Version 2.1.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="PdfForge.Avalonia" Version="2.1.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PdfForge.Avalonia" Version="2.1.2" />
                    
Directory.Packages.props
<PackageReference Include="PdfForge.Avalonia" />
                    
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 PdfForge.Avalonia --version 2.1.2
                    
#r "nuget: PdfForge.Avalonia, 2.1.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 PdfForge.Avalonia@2.1.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=PdfForge.Avalonia&version=2.1.2
                    
Install as a Cake Addin
#tool nuget:?package=PdfForge.Avalonia&version=2.1.2
                    
Install as a Cake Tool

PdfForge.Avalonia

NuGet

PdfForge.Avalonia is a library that provides a custom PdfView control for rendering and displaying PDF documents in Avalonia UI applications. The control is built on top of the PdfForge library, offering smooth PDF rendering and easy integration into Avalonia applications.

Features

  • Display PDF documents inside Avalonia applications.
  • Render specific pages with customizable scale.
  • Panning support for easy navigation within the document.
  • Show loading indicators during rendering.
  • Expose document dimensions for flexible UI layouts.

Installation

Install the PdfForge.Avalonia package via NuGet:

dotnet add package PdfForge.Avalonia

You also need to add styles in your app:

<Application.Styles>
    <FluentTheme />
    <StyleInclude Source="avares://PdfForge.Avalonia/Styles.axaml"/>
</Application.Styles>

Usage

XAML Example

You can use the PdfView control directly in your XAML to display PDF content. Bind the Document, PageNumber, and Scale properties to control the document and rendering behavior:

<Window
xmlns:avalonia="clr-namespace:PdfForge.Avalonia;assembly=PdfForge.Avalonia">

<avalonia:PdfView Document="{Binding PdfDocument}"
                  PageNumber="{Binding PageNumber}"
                  Scale="{Binding Scale}" />
</Window>

Code-Behind Example

You can control the PdfView via code by setting properties like Document, PageNumber, and Scale:

var pdfView = new PdfView
{
    Document = new PdfForgeDocument("sample.pdf"),
    PageNumber = 0,
    Scale = 1.0
};

Basic Example (XAML with Button Controls)

Here’s an example that demonstrates how to integrate PdfView with buttons for page navigation and zoom:

<Grid>
    <avalonia:PdfView x:Name="PdfViewer"
                      Document="{Binding PdfDocument}"
                      PageNumber="{Binding PageNumber}"
                      Scale="{Binding Scale}" />
    
    <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom">
        <Button Content="Previous Page" Command="{Binding PrevPageCommand}" />
        <Button Content="Next Page" Command="{Binding NextPageCommand}" />
        <Button Content="Zoom In" Command="{Binding ZoomInCommand}" />
        <Button Content="Zoom Out" Command="{Binding ZoomOutCommand}" />
    </StackPanel>
</Grid>

Control Properties

  • Document: The PdfForgeDocument instance to render.
  • PageNumber: The current page number to display.
  • Scale: The scaling factor for the PDF page rendering.

Requirements

  • GNU/Linux OS

  • .NET 8.0+

  • Avalonia UI for building the user interface (11.1.4+).

  • PdfForge library for PDF rendering.

  • Following system packages to be installed:

    • libpoppler-glib-dev
    • libcairo2-dev
    • libglib2.0-dev

    Package names may vary depending on the distribution.

🚫 Windows and macOS are NOT supported due to dependencies on Linux-specific libraries (Poppler, Cairo, GLib).

License

This project is licensed under the GPL-3.0 license.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.1.2 196 2/14/2025
1.1.4 138 10/24/2024
1.1.3 111 10/24/2024
1.1.2 118 10/24/2024
1.1.1 124 10/24/2024

Initial release of PdfForge.Avalonia.