Developer Tools
|
Office Productivity Applications
|
Enterprise Solutions
|
|||||||||||||||||||||||







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 Developer Tools | |
|---|---|
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. |
XtremePDFConverter VCLA Delphi/C++Builder component to intelligently convert PDF to user-friendly Word RTF documents. |
|
PDFOne .NETA .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications. |
XtremeDocumentStudio .NETMulti-format document-processing component suite for .NET developers |
PDFOne (for Java™)A Java™ PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java™ applications. |
XtremeFontEngine (for Java)Java font engine to render glyphs from Type 1, Type 2 (CFF), and TrueType fonts |
| Our Office Productivity Applications |
|---|
Free PDF ReaderA free, fast, and portable application for viewing, printing and converting PDF documents. |
| Privacy | Legal | Feedback | Newsletter | Resellers | © 2002-2013 Gnostice Information Technologies Private Limited. All rights reserved. |
This site is best viewed on a screen with minimum resolution of 1152 x 864 pixels. Windows XP users are advised to use Microsoft ClearType Tuning for optimal experience. Also, please use the latest version of a standards-compliant browser such as Firefox, Opera, or Dragon (Chromium).