PDF VIEWER COMPONENT
FOR WINDOWS DESKTOP
A quick overview of the functionality featured in the PDF Viewer component of PDFPrinting.NET, including a few examples for a quick preview. For detailed information, please consult the reference documentation found in the help section.
NEW!
ASP.NET CORE PDF VIEWER
Display your PDF documents with ease thanks to our PDF web viewer which can be easly integrated with ASP.NET Core Razor pages, MVC, Blazor or Webassembly apps/websites.
- Display PDF from a file or byte array.
- Configure control look and feel.
- Built-in search and highlight functionality.
- Track pages and its position in display.
- Retrieve document properties.
- Bookmark view.
- Supports Zoom and Pan.
- Display PDF forms.
- Print PDF using our PDFPrinting library.
PDF VIEWER .NET COMPONENT FEATURES
SIMPLE SILENT PRINTING OF PDF FILES
PDF VIEWER .NET COMPONENT FEATURES
The demo doesn't have the 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.
LIST OF FEATURES
Open PDF Document
Print PDF Document
PDF Page navigation
PDF Selection
Search trought PDF document
Manage zoom in PDF document
OPEN DOCUMENT
This example 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 PDF 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
You can print PDF document and subscribe to the print events.
var pdfViewer = new PdfViewer();
pdfViewer.OpenDocument(@"c:\test\test.pdf");
// list of available default predefined zoom values (like 50, 75, 100, 125...)
var availableZoomValues = pdfViewer.GetAvailableZoomLevels();
//next bigger default available zoom level
pdfViewer.ZoomIn();
// previous smaller default available zoom level
pdfViewer.ZoomOut();
// zoom to page level
pdfViewer.ZoomValue = (float)Math.Round(pdfViewer.FitToPageZoomValue * 100, 2);
var minZoomValue = pdfViewer.GetMinZoomLevel();
var maxZoomValue = pdfViewer.GetMaxZoomLevel();
//in % of the actual PDF size (value 100 means show actual PDF page size)
pdfViewer.ZoomValue = 70;
SEARCH TROUGHT PDF DOCUMENT
Example how to search PDF document from code.
var pdfPrint = new PdfPrint("demoCompany", "demoKey");
string pdfFile = @"c:\test\test.pdf";
var status =pdfPrint.PrintWithAdobe(pdfFile);
PrinterSettings printerSettings = YourCustomMethodWhichReturnsPrinterSettings();
status = pdfPrint.PrintWithAdobe(pdfFile, printerSettings);
MANAGE PDF DOCUMENT ZOOM
Example how to get or change zoom value of PDF document.
var pdfPrint = new PdfPrint("demoCompany", "demoKey");
string pdfFile = @"c:\test\test.pdf";
PrinterSettings printerSettings = YourCustomMethodWhichReturnsPrinterSettings();
var status =pdfPrint.Print(pdfFile, printerSettings);
// if you have pdf document in byte array that is also supported
byte[] pdfContent = YourCustomMethodWhichReturnsPdfDocumentAsByteArray();
status = pdfPrint.Print(pdfContent, printerSettings);
// if you have pdf document in byte array that is also supported
pdfPrint.SettingDialog = true;//it will show printer dialog
status = pdfPrint.Print(pdfFile);
OPEN DOCUMENT
This example 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 PDF 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
You can print PDF document and subscribe to the print events.
var pdfViewer = new PdfViewer();
pdfViewer.OpenDocument(@"c:\test\test.pdf");
// list of available default predefined zoom values (like 50, 75, 100, 125...)
var availableZoomValues = pdfViewer.GetAvailableZoomLevels();
//next bigger default available zoom level
pdfViewer.ZoomIn();
// previous smaller default available zoom level
pdfViewer.ZoomOut();
// zoom to page level
pdfViewer.ZoomValue = (float)Math.Round(pdfViewer.FitToPageZoomValue * 100, 2);
var minZoomValue = pdfViewer.GetMinZoomLevel();
var maxZoomValue = pdfViewer.GetMaxZoomLevel();
//in % of the actual PDF size (value 100 means show actual PDF page size)
pdfViewer.ZoomValue = 70;
SEARCH TROUGHT PDF DOCUMENT
Example how to search PDF document from code.
var pdfPrint = new PdfPrint("demoCompany", "demoKey");
string pdfFile = @"c:\test\test.pdf";
var status =pdfPrint.PrintWithAdobe(pdfFile);
PrinterSettings printerSettings = YourCustomMethodWhichReturnsPrinterSettings();
status = pdfPrint.PrintWithAdobe(pdfFile, printerSettings);
MANAGE PDF DOCUMENT ZOOM
Example how to get or change zoom value of PDF document.
var pdfPrint = new PdfPrint("demoCompany", "demoKey");
string pdfFile = @"c:\test\test.pdf";
PrinterSettings printerSettings = YourCustomMethodWhichReturnsPrinterSettings();
var status =pdfPrint.Print(pdfFile, printerSettings);
// if you have pdf document in byte array that is also supported
byte[] pdfContent = YourCustomMethodWhichReturnsPdfDocumentAsByteArray();
status = pdfPrint.Print(pdfContent, printerSettings);
// if you have pdf document in byte array that is also supported
pdfPrint.SettingDialog = true;//it will show printer dialog
status = pdfPrint.Print(pdfFile);