Developer Tools
|
Office Productivity Applications
|
Platform-Agnostic APIs
|
Home | Online Demos | Downloads | Buy Now | Support | About Us | News | Working Together | Contact Us
This is an updated version of an older article. That article was written for PDFOne .NET v2.0 Preview, where the viewer was part of Gnostice.PDFOne
assembly.
When version 2.0 was finally released, the PDF viewer component was provided in a separate assembly named Gnostice.PDFOne.Windows.PDFViewer
. Hence, a newer version of the article was due. PDFViewer is a .NET PDF viewer component that you can use to display PDF documents to end-users in Win-forms applications.
All right and here we go. Let us build a Winforms PDF viewer application.
toolStrip1
. In VB.NET, it will be ToolStrip1
.) Ensure that the strip is right below the title bar and its Dock property is set to Top.pdfViewer1
. In VB.NET, it will be named PdfViewer1
.tb_Filename
. Resize it so that it looks like the address bar of a browser.btn_Open
, btn_FirstPage
, btn_PreviousPage
, btn_NextPage
, and btn_LastPage
. Also, set their DisplayStyle to Text and Text properties to "First Page", "Previous Page", Next Page", and "Last Page".btn_Open
and add the following code for its click event.
tb_Filename.Text = tb_Filename.Text.Trim(); if (tb_Filename.Text == "") { return; } // Close any previously loaded document if (pdfViewer1.PDFLoaded) { pdfViewer1.CloseDocument(); } // Load PDF document try { pdfViewer1.LoadDocument(tb_Filename.Text); } catch (Exception ex1) { MessageBox.Show( "Sorry. There has been an error. Error Information: " + ex1.Message); return; } // Update form title bar this.Text = "PDFOne .NET Viewer - " + tb_Filename.Text;
tb_Filename.Text = Trim(tb_Filename.Text) If Trim(tb_Filename.Text) = "" Then Exit Sub End If ' Close any previously loaded document If PdfViewer1.PDFLoaded Then PdfViewer1.CloseDocument() End If ' Load PDF document Try PdfViewer1.LoadDocument(tb_Filename.Text) Catch Ex1 As Exception MessageBox.Show( _ "Sorry. There has been an error. Error Information: " _ & Ex1.Message) Exit Sub End Try ' Update form title bar Me.Text = "PDFOne .NET Viewer Component Demo - " & tb_Filename.Text
private void btn_PreviousPage_Click(object sender, EventArgs e) { pdfViewer1.PreviousPage(); } private void btn_FirstPage_Click(object sender, EventArgs e) { pdfViewer1.FirstPage(); } private void btn_NextPage_Click(object sender, EventArgs e) { pdfViewer1.NextPage(); } private void btn_LastPage_Click(object sender, EventArgs e) { pdfViewer1.LastPage(); }
Private Sub btn_FirstPage_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles btn_FirstPage.Click PdfViewer1.FirstPage() End Sub Private Sub btn_PreviousPage_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles btn_PreviousPage.Click PdfViewer1.PreviousPage() End Sub Private Sub btn_NextPage_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles btn_NextPage.Click PdfViewer1.NextPage() End Sub Private Sub btn_LastPage_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles btn_LastPage.Click PdfViewer1.LastPage() End Sub
---o0O0o---
Our .NET Developer Tools | |
---|---|
Gnostice Document Studio .NETMulti-format document-processing component suite for .NET developers. |
PDFOne .NETA .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications. |
Our Delphi/C++Builder developer tools | |
---|---|
Gnostice Document Studio DelphiMulti-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms. |
eDocEngine VCLA Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools. |
PDFtoolkit VCLA Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents. |
Our Java developer tools | |
---|---|
Gnostice Document Studio JavaMulti-format document-processing component suite for Java developers. |
PDFOne (for Java)A Java PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java applications. |
Our Platform-Agnostic Cloud and On-Premises APIs | |
---|---|
StarDocsCloud-hosted and On-Premises REST-based document-processing and document-viewing APIs |
Privacy | Legal | Feedback | Newsletter | Blog | Resellers | © 2002-2024 Gnostice Information Technologies Private Limited. All rights reserved. |