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
<PackageReference Include="ADaxer.Pdf.Wpf" Version="1.0.0" />
paket add ADaxer.Pdf.Wpf --version 1.0.0
#r "nuget: ADaxer.Pdf.Wpf, 1.0.0"
// 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:
- 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.
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>
Bind the Properties: Bind the properties (
PdfBytes
,Zoom
,ViewMode
,CurrentPage
) to your view model or code-behind as needed.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;
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 | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0-windows7.0 is compatible. |
-
net8.0-windows7.0
- PDFiumCore (>= 128.0.6569)
- SixLabors.ImageSharp (>= 3.1.5)
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.