ADaxer.Pdf.Wpf 1.0.0

dotnet add package ADaxer.Pdf.Wpf --version 1.0.0                
NuGet\Install-Package ADaxer.Pdf.Wpf -Version 1.0.0                
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="ADaxer.Pdf.Wpf" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ADaxer.Pdf.Wpf --version 1.0.0                
#r "nuget: ADaxer.Pdf.Wpf, 1.0.0"                
#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.
// Install ADaxer.Pdf.Wpf as a Cake Addin
#addin nuget:?package=ADaxer.Pdf.Wpf&version=1.0.0

// Install ADaxer.Pdf.Wpf as a Cake Tool
#tool nuget:?package=ADaxer.Pdf.Wpf&version=1.0.0                

WPF PDF Viewer Control

A free PDF viewer control for WPF applications.

To the best of my knowledge, there is currently no other free PDF viewer available for WPF, so I created one, as I needed it in a recent customer project.

Overview

PdfView is a custom WPF control designed to easily display PDF documents within WPF applications. It features:

  • Zooming: Easily zoom in and out of PDF pages.
  • Navigation: Navigate between pages using commands for next and previous pages.
  • View Modes: Switch between different view modes, including single-page, double-page, and scrolling modes.
  • Fit to Width/Height: Commands to automatically adjust the zoom level to fit the width or height of the control.

Demo Application

A demo WPF application to demonstrate how to use the PdfView control is provided, so check out the ADaxer.Pdf.Wpf.DemoApp (which uses the wonderful MaterialDesignInXaml toolkit).

Getting started

To use the PdfView control in your WPF project, follow these simple steps:

  1. Add it to Your Project
  • by copying the source code or by adding it as a project reference.

  • Or by adding the NuGet Package:

    dotnet add package PdfViewerControl --version 1.0.0
    

    You can find the package here.

  1. XAML Usage: Add the PdfView control to your XAML file.

    <Window x:Class="YourNamespace.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:adaxer="http://adaxer.de/pdf/wpf"
            Title="PDF Viewer" >
        <Grid>
            <adaxer:PdfView x:Name="pdfViewer"
                           PdfBytes="{Binding PdfBytes}"
                           Zoom="{Binding ZoomLevel}"
                           ViewMode="{Binding SelectedViewMode}"
                           CurrentPage="{Binding CurrentPage}" />
        </Grid>
    </Window>
    
  2. Bind the Properties: Bind the properties (PdfBytes, Zoom, ViewMode, CurrentPage) to your view model or code-behind as needed.

  3. Load PDF Data: Load a PDF file into the PdfBytes property as a byte array.

    byte[] pdfData = File.ReadAllBytes("path/to/your/file.pdf");
    pdfViewer.PdfBytes = pdfData;
    
  4. Use Commands: Use the commands provided by the control to navigate and interact with the PDF.

    // Zoom in
    pdfViewer.ZoomInCommand.Execute(null);
    
    // Move to the next page
    pdfViewer.NextPageCommand.Execute(null);
    

External dependencies

The image processing of the Pdf is done via PdfiumCore and uses ImageSharp, apart from that there are no dependencies.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible. 
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
1.0.0 177 8/21/2024

Initial release.