Skip to content
/ Pdf.Wpf Public

A PDF viewer for WPF projects with paging, zooming and convenience functions using PdfiumCore

License

Notifications You must be signed in to change notification settings

adaxer/Pdf.Wpf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A PDF viewer for WPF projects with paging, zooming and convenience functions using PdfiumCore

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages