PDF Viewer Component

Display PDFs with
Pixel-Perfect Rendering

A powerful PDF viewer component for Windows desktop applications. Drag, drop, and display PDF documents with full zoom, search, and selection capabilities.

document.pdf - PdfViewer
1 / 12
100%
1
2
3
Display PDF from file or byte array
Built-in search and highlight functionality
Supports zoom and pan operations
Display PDF forms and bookmarks
Track pages and position in display
Retrieve document properties
NEW

ASP.NET Core PDF Viewer for Web

Display PDF documents in your web applications with our PDF web viewer, designed for seamless integration with ASP.NET Core Razor Pages, MVC, Blazor, and WebAssembly.

Visit Product Page

Code Examples

Explore how to integrate the PDF Viewer component into your .NET applications

Open Document

Open a PDF document and use the status of the open operation. Subscribe to the DocumentLoaded event for async notifications.

C#
var pdfViewer = new PdfViewer();
pdfViewer.DocumentLoaded += PdfViewer_DocumentLoaded;
PdfOpenFileStatus status = pdfViewer.OpenDocument(@"c:\test\test.pdf");

string msg = "";
if (status.Result == PdfOpenFileStatus.PdfOpenFileResult.OK)
    msg = string.Format("Document has {0} pages. Current page is {1}.",
        pdfViewer.NumberOfPages, pdfViewer.CurrentPageNumber);
else
    msg = "Problem loading document. Status = " + status.Result.ToString();

MessageBox.Show(msg);

private void PdfViewer_DocumentLoaded(object sender, DocumentLoadedEventArgs e)
{
    MessageBox.Show("Document " + e.FileName + " was loaded");
}

Print PDF Document

Print the PDF document directly from the viewer and subscribe to print events for progress tracking.

C#
var pdfViewer = new PdfViewer();
pdfViewer.OpenDocument(@"c:\test\test.pdf");

// Subscribe to print events
pdfViewer.DocumentPrintBegin += PdfViewer_DocumentPrintBegin;
pdfViewer.DocumentPrintEnd += PdfViewer_DocumentPrintEnd;
pdfViewer.DocumentPrintPageBegin += PdfViewer_DocumentPrintPageBegin;
pdfViewer.DocumentPrintPageEnd += PdfViewer_DocumentPrintPageEnd;

PdfPrint.Status status = pdfViewer.Print();

private void PdfViewer_DocumentPrintPageBegin(object sender,
    PdfPrint.DocumentPrintPageEventArgs e)
{
    string msg = "Print page begin. Page " + e.PageNumber +
        " of " + e.TotalNumberOfPagesToPrint;
}

PDF Page Navigation

Navigate through PDF pages programmatically with various methods and track page history.

C#
var pdfViewer = new PdfViewer();
pdfViewer.OpenDocument(@"c:\test\test.pdf");
pdfViewer.CurrentPageChanged += PdfViewer_CurrentPageChanged;

// Navigation methods
pdfViewer.GoToLastPage();
pdfViewer.GoToFirstPage();
pdfViewer.GoToNextPage();
pdfViewer.GoToPreviousVisitedPage();
pdfViewer.GoToPage(pdfViewer.NumberOfPages); // go to last page
pdfViewer.GoToPreviousPage();
pdfViewer.GoToNextVisitedPage();

// Page info properties
int currentPage = pdfViewer.CurrentPageNumber;
int currentVisitedPageIndex = pdfViewer.CurrentVisitedPageIndex;
List<int> visitedPages = pdfViewer.VisitedPages;

private void PdfViewer_CurrentPageChanged(object sender, CurrentPageEventArgs e)
{
    MessageBox.Show("Current page now is " + e.CurrentPage);
}

PDF Selection

Enable text and image selection within PDF documents for user interaction.

C#
var pdfViewer = new PdfViewer();
pdfViewer.OpenDocument(@"c:\test\test.pdf");

// Enable selection mode
pdfViewer.SelectionMode = SelectionMode.Text;

// Get selected text
string selectedText = pdfViewer.GetSelectedText();

// Copy selection to clipboard
pdfViewer.CopySelectionToClipboard();

// Clear selection
pdfViewer.ClearSelection();

// Selection changed event
pdfViewer.SelectionChanged += (s, e) => {
    Console.WriteLine("Selection changed: " + e.SelectedText);
};

Manage PDF Zoom

Control zoom levels programmatically with preset values or custom percentages.

C#
var pdfViewer = new PdfViewer();
pdfViewer.OpenDocument(@"c:\test\test.pdf");

// Get available zoom levels (50, 75, 100, 125...)
var availableZoomValues = pdfViewer.GetAvailableZoomLevels();

// Zoom in/out to next preset level
pdfViewer.ZoomIn();
pdfViewer.ZoomOut();

// Set zoom to fit page
pdfViewer.ZoomValue = (float)Math.Round(
    pdfViewer.FitToPageZoomValue * 100, 2);

// Get zoom limits
var minZoom = pdfViewer.GetMinZoomLevel();
var maxZoom = pdfViewer.GetMaxZoomLevel();

// Set custom zoom (100 = actual size)
pdfViewer.ZoomValue = 70;
Open PDF Document

Open a PDF document and handle the status of the open operation.

C#
var pdfViewer = new PdfViewer();
PdfOpenFileStatus status = pdfViewer.OpenDocument(@"c:\test\test.pdf");
if (status.Result == PdfOpenFileStatus.PdfOpenFileResult.OK)
    Console.WriteLine("Pages: " + pdfViewer.NumberOfPages);
Print PDF Document

Print the PDF document and subscribe to print events.

C#
var pdfViewer = new PdfViewer();
pdfViewer.OpenDocument(@"c:\test\test.pdf");
PdfPrint.Status status = pdfViewer.Print();
PDF Page Navigation

Navigate through PDF pages with various methods.

C#
pdfViewer.GoToFirstPage();
pdfViewer.GoToLastPage();
pdfViewer.GoToPage(5);
int currentPage = pdfViewer.CurrentPageNumber;
PDF Selection

Enable text and image selection within PDF documents.

C#
pdfViewer.SelectionMode = SelectionMode.Text;
string text = pdfViewer.GetSelectedText();
pdfViewer.CopySelectionToClipboard();
Search PDF Document

Search for text within PDF documents.

C#
var results = pdfViewer.Search("search term");
pdfViewer.GoToNextSearchResult();
pdfViewer.HighlightSearchResults = true;
Manage PDF Zoom

Control zoom levels programmatically.

C#
pdfViewer.ZoomIn();
pdfViewer.ZoomOut();
pdfViewer.ZoomValue = 150; // 150%

Ready to Get Started?

Download the free demo and start displaying PDFs in your .NET applications today.

Download Free Demo