DocViewer.Android 3.0.8

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

PdfViewer for .NET Android

A robust .NET for Android binding library for the Pdf-Viewer library. This library provides a feature-rich, customizable PDF viewer component for Xamarin.Android and .NET Android applications.

Features

  • Multiple Loading Sources: Load PDFs from URL, File, Assets, or URI.
  • Advanced Navigation: Horizontal/Vertical scrolling, Single Page mode, Wrapped mode.
  • Page Layout: Spread modes (Odd/Even), Page Snapping, Single Page Arrangement.
  • Complete UI System: Includes PdfToolBar, PdfScrollBar, and PdfViewerContainer for a drop-in UI.
  • Editor Capabilities: Built-in support for basic annotation actions (Undo/Redo) and property customization.
  • Customizable: Extensive API to control visual properties and alignment.
  • Zero Warnings: Clean build with no binding warnings.

Installation

Add the PdfViewer.Binding project or DLL to your .NET Android solution.

  1. Add PdfViewer.Binding.csproj to your solution.
  2. Add a project reference from your App project to PdfViewer.Binding.

Getting Started

1. XML Layout

The library provides a composed UI container PdfViewerContainer that automatically manages the Viewer, Toolbar, and ScrollBar.

<com.bhuvaneshw.pdf.ui.PdfViewerContainer
    android:id="@+id/pdfViewerContainer"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    
    <com.bhuvaneshw.pdf.ui.PdfToolBar
        android:id="@+id/pdfToolBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    
    <com.bhuvaneshw.pdf.PdfViewer
        android:id="@+id/pdfViewer"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    
    <com.bhuvaneshw.pdf.ui.PdfScrollBar
        android:id="@+id/pdfScrollBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
        
</com.bhuvaneshw.pdf.ui.PdfViewerContainer>

2. Basic Initialization (C#)

In your Activity or Fragment:

using Com.Bhuvaneshw.Pdf;
using Com.Bhuvaneshw.Pdf.UI;

// ... Inside OnCreate

// 1. Find References
var viewer = FindViewById<PdfViewer>(Resource.Id.pdfViewer);
var container = FindViewById<PdfViewerContainer>(Resource.Id.pdfViewerContainer);
var toolbar = FindViewById<PdfToolBar>(Resource.Id.pdfToolBar);
var scrollBar = FindViewById<PdfScrollBar>(Resource.Id.pdfScrollBar);

// 2. Setup Dependencies
toolbar.SetupWith(viewer);
scrollBar.SetupWith(viewer, toolbar, false); // false = force update

// 3. Load PDF
viewer.LoadFromUrl("https://example.com/sample.pdf");
// OR
// viewer.LoadFromAsset("sample.pdf");

detailed API Reference

Loading Content

Method Description
LoadFromUrl(string url) Loads a PDF from a remote URL.
LoadFromAsset(string assetName) Loads a PDF from the application's Assets folder.
LoadFromFile(File file) Loads a PDF from a local Java.IO.File.
LoadFromFileUri(Uri uri) Loads a PDF from an Android Uri.

Configuration Properties

The PdfViewer class exposes several properties to control behavior and appearance.

Scroll Mode (PdfViewer.ScrollMode)

Controls how pages are scrolled.

  • PageScrollMode.Horizontal: Standard horizontal scrolling.
  • PageScrollMode.Vertical: Standard vertical scrolling (Default).
  • PageScrollMode.SinglePage: Displays one page at a time.
  • PageScrollMode.Wrapped: Wraps pages like a continuous document.
viewer.ScrollMode = PdfViewer.PageScrollMode.Horizontal;
Spread Mode (PdfViewer.SpreadMode)

Controls page spreads (like a book view).

  • PageSpreadMode.None: Single page view (Default).
  • PageSpreadMode.Odd: Starts with an odd page.
  • PageSpreadMode.Even: Starts with an even page.
viewer.SpreadMode = PdfViewer.PageSpreadMode.Odd;
Align Mode (PdfViewer.AlignMode)

Controls page alignment within the viewport.

  • PageAlignMode.Start
  • PageAlignMode.CenterHorizontal
  • PageAlignMode.CenterVertical
  • PageAlignMode.CenterBoth
  • etc.
viewer.AlignMode = PdfViewer.PageAlignMode.CenterBoth;
Other Properties
  • SnapPage (bool): If true, scrolling snaps to the nearest page edge.
  • SinglePageArrangement (bool): Optimized arrangement for single page viewing.
  • PageRotation (int): Rotation angle in degrees (0, 90, 180, 270).
  • DoubleClickThreshold (long): Time in ms for detecting double clicks.
  • LongClickThreshold (long): Time in ms for detecting long clicks.
  • ScrollSpeedLimit (float): Max scroll speed multiplier.

PdfToolBar Customization

The PdfToolBar provides built-in navigation and actions.

  • Handling Back Button: Because OnBack expects a Kotlin function, use a helper class implementation:

    private class BackAction : Java.Lang.Object, Kotlin.Jvm.Functions.IFunction0 {
        private readonly Activity _act;
        public BackAction(Activity a) => _act = a;
        public Java.Lang.Object Invoke() { _act.Finish(); return null; }
    }
    
    toolbar.OnBack = new BackAction(this);
    

PdfEditor

Access annotation features via the Editor property.

// Undo/Redo
viewer.Editor.Undo();
viewer.Editor.Redo();

// Customization
viewer.Editor.HighlightColor = Android.Graphics.Color.Yellow;
viewer.Editor.InkColor = Android.Graphics.Color.Red;

Requirements

  • .NET 10 Android
  • Android SDK 23+ (Min SDK)

Build Instructions

cd PdfViewer.Binding
dotnet build
Product Compatible and additional computed target framework versions.
.NET net10.0-android36.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
3.0.8 449 12/11/2025