PDF Viewer Component

A quick overview of the functionality featured in the PDF Viewer component of PDFPrinting.NET. For detailed information, please consult the reference documentation found in the help section.

PDF Viewer .NET component features

Perfect PDF Rendering for your .NET project

Using the same rendering engine as for our printing library the viewer component will display you a perfectly rendered PDF document. The control comes with multiple rendering modes allowing you to choose a preferred way of rendering PDFs.

Just drag and drop

The PDFPrinting.NET Viewer component offers the simplicity of use and an API. API allows you to tune both the representation and behavior of the component. But to get started all you need is just to drag and drop the component from the Visual Studio toolbox onto your form.

Fully selectable PDF text

Besides just rendering the pages the component allows you to select any text or image in your PDF documents. You can do this programmatically or allow your end users to select the text. That also includes the ability to search the content of the documents.

Fast rendering and low resource usage

As the renderer uses our printing library, it has years of improvements based on real life situations to render as fast as possible and at the same time to use as little as possible resources.

Download and test if for free

Try PDFPrinting.NET Viewer Demo

The demo doesn't have time or functionality limitations. It only imposes a nonobstructive watermark over your printouts or the viewer component. Once you purchase a license, the watermarks will be removed, and you can continue to use the product with the already implemented code.

PDF Viewer .NET component source code examples

Open Document

This examples shows how to open a PDF document and use status of the open operation. Also, it illustrates how to subscribe to DocumentLoaded event.

  • 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, pdfViewer1.CurrentPageNumber);
  • else
  •        msg = "There was a problem loading document. Status = " + status.Result.ToString() + "
  •            Additional information = " + status.Status;
  • MessageBox.Show(msg);

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

Print document

You can print PDF document and subscribe to the print events.

  • var pdfViewer = new PdfViewer();
  • pdfViewer.OpenDocument(@"c:\test\test.pdf");
  • 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. CurrentPageIndex=" + e.CurrentPageIndex + " Page Number=" +
  •        e.PageNumber + " Total Pages to Print=" + e.TotalNumberOfPagesToPrint;
  • }

  • private void PdfViewer_DocumentPrintPageEnd(object sender,
  • PdfPrint.DocumentPrintPageEventArgs e)
  • {
  •        string msg = "Print page end. CurrentPageIndex=" + e.CurrentPageIndex + " Page Number=" +
  •        e.PageNumber + " Total Pages to Print=" + e.TotalNumberOfPagesToPrint;
  • }

  • private voidPdfViewer_DocumentPrintEnd(object sender, PdfPrint.DocumentPrintEndEventArgs e)
  • {
  •        string msg = "Print document end. Document = " + e.FileName + "Status=" + e.Status +
  •        " Number of pages in document=" + e.NumberOfPagesInDocument +
  •        " Number of pages printed:" + e.NumberOfPagesPrinted;
  • }

  • private void PdfViewer_DocumentPrintBegin(object sender, PdfPrint.DocumentPrintBeginEventArgs e)
  • {
  •        string msg = "Print document end. Document = " + e.FileName +
  •        " Number of pages in document=" + e.NumberOfPagesInDocument +
  •        " Number of pages to print=" + e.NumberOfPagesToPrint;
  • }

PDF Page navigation

This example shows different methods and properties for navigating through PDF document.

  • var pdfViewer = new PdfViewer();
  • pdfViewer.OpenDocument(@"c:\test\test.pdf");
  • pdfViewer.CurrentPageChanged += PdfViewer_CurrentPageChanged;
  • pdfViewer.GoToLastPage();
  • pdfViewer.GoToFirstPage();
  • pdfViewer.GoToNextPage();
  • pdfViewer.GoToPreviousVisitedPage();
  • pdfViewer.GoToPage(pdfViewer.NumberOfPages);// go to last page
  • pdfViewer.GoToPreviousPage();
  • pdfViewer.GoToNextVisitedPage();
  • // This are just getters
  • 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

This example shows how to select text or retrieve selected text/image.

  • var pdfViewer = new PdfViewer();
  • pdfViewer.OpenDocument(@"c:\test\test.pdf");
  • pdfViewer.SelectionChanged += PdfViewer_SelectionChanged;
  • pdfViewer.SelectionColor = Color.LightGreen;
  • pdfViewer.SelectAllText(1); // it will select all text on first page
  • string textOnFirstPage = pdfViewer.GetSelectedText();
  • Image image = pdfViewer.GetSelectedImage();
  • pdfViewer.SelectionDisabled = true; // selection will not be possible

  • private void PdfViewer_SelectionChanged(object sender, SelectionEventArgs e)
  • {
  •        MessageBox.Show("Selection Type is" + e.SelectionType + " and number of selected items is " + e.SelectedCount);
  • }

Search through PDF document

Example how to search PDF document from code.

  • var pdfViewer = new PdfViewer();
  • pdfViewer.OpenDocument(@"c:\test\test.pdf");
  • string searchTerm = "test";
  • bool isCaseSensitive = true;
  • bool wholeWordOnly = true;
  • // it will select next occurrence of testWord
  • pdfViewer.SearchNext(searchTerm, isCaseSensitive, wholeWordOnly);
  • // it will select previous occurrence of testWord
  • pdfViewer.SearchPrevious(searchTerm, isCaseSensitive, wholeWordOnly);

Zoom PDF document

Example how to get or change zoom value of PDF document.

  • var pdfViewer = new PdfViewer();
  • pdfViewer.OpenDocument(@"c:\test\test.pdf");
  • string searchTerm = "test";
  • bool isCaseSensitive = true;
  • bool wholeWordOnly = true;
  • // it will select next occurrence of testWord
  • pdfViewer.SearchNext(searchTerm, isCaseSensitive, wholeWordOnly);
  • // it will select previous occurrence of testWord
  • pdfViewer.SearchPrevious(searchTerm, isCaseSensitive, wholeWordOnly);
Ready to download and test if for free?

Try PDFPrinting.NET Viewer Demo

The only limitation of this demo is displayed watermark over your printed material or in the viewer component. When you apply purchased license, the watermark will not be shown anymore.