Developer Tools
|
Office Productivity Applications
|
Platform-Agnostic APIs
|
Home | Online Demos | Downloads | Buy Now | Support | About Us | News | Working Together | Contact Us
PDFViewer
is the viewer component in PDFOne .NET. It is a multi-page PDF viewer and supports advanced features such as zooming, rotation, mousewheel scrolling, and keyboard shortcuts.
You can use the PDFViewer in a .NET Win forms application to display PDF documents. This can be very useful in an application that generates PDF statements or invoices and the user requires a preview before the document is e-mailed to recipients.
Or, if you were developing a multi-format document viewing application, somewhat similar to our ONEView application, (which does more than just displaying documents), then you may want the ability to display PDF documents that are simply dragged and dropped on the form.
PDFViewer can be programmed to support for drag-and-drop operations. For this, you need to handle the inherited Control.DragDrop
event of the viewer like this.
private void pdfViewer1_DragDrop(object sender, DragEventArgs e) { // Check for a valid file drop if (e.Data.GetDataPresent(DataFormats.FileDrop)) { // Get names of files that were dropped string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); if (files.Length > 0) { // Display the first file that is droppped. pdfViewer1.LoadDocument(files[0]); } } }
To ensure that only a PDF document is loaded by the viewer, you can handle the inherited Control.DragEnter
event as shown below.
private void pdfViewer1_DragEnter(object sender, DragEventArgs e) { // Do not allow file drop (initially) e.Effect = DragDropEffects.None; if (!e.Data.GetDataPresent(DataFormats.FileDrop)) { return; } string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); if (files.Length > 0) { // Allow file drop for PDF files if (files[0].EndsWith(".pdf", true, null)) { e.Effect = DragDropEffects.Copy; } } }
For these events to fire, you need to set the PDFViewer.AllowDrop
property to true. You can add these event handlers to the .NET PDF viewer project described in the last month's article How To Create A PDF Viewer in PDFOne .NET v2.x and they will work fine.
---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. |