c#pdf查看器
Free Spire.PDF for .NET is a Community Edition of the Spire.PDF for .NET, which is a totally free PDF component for commercial and personal use. As a standalone C#/VB.NET component, Free Spire.PDF for .NET enables developers to create, write, edit, convert, print, handle and read PDF files on any .NET applications.
本篇文章将介绍用e-iceblue插件开发简单的pdf查看器。
e-iceblue提供包括处理office在内的所有插件,地址:http://www.e-iceblue.com/
http://www.e-iceblue.com/Introduce/free-pdf-component.html下载免费版的pdf插件安装完成后,就可以看到下面的demo窗体。该窗体展示了所有操作pdf的样例和代码,你也可以直接运行demo
该pdf插件将处理附件、标注、导出、打开、分页、打印、存储等相关pdf操作。
新建vs2012 winform程序,将C:\Program Files (x86)\e-iceblue\Spire.PdfViewer-FE\Bin下的相应版本dll导入vs2012工具栏,
将PfdViewer控件拖至新建窗体上,Spire.PdfViewer的引用就算完成了。
this.pdfDocumentViewer1.LoadFromFile函数是加载一个pdf文件,参数是文件路径。
this.pdfDocumentViewer1.Print函数是打印当前文档。
下面是获取注解和转到注解的代码
/// <summary>
/// 获取pdf注解
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnAttachmentAnnotation_Click(object sender, EventArgs e)
{
this.tableLayoutPanel1.SetRowSpan(this.pdfDocumentViewer1, );
this.m_isAttachmentAnnotation = true;
this.listView1.Visible = true;
this.listView1.Items.Clear();
this.listView1.Columns.Clear();
if (this.pdfDocumentViewer1.IsDocumentLoaded && this.pdfDocumentViewer1.PageCount > )
{
this.listView1.View = View.Details;
this.listView1.Columns.Add("注解",);
this.listView1.Columns.Add("内容",);
this.listView1.Columns.Add("页码",);
this.listView1.Columns.Add("位置",);
//获取pdf注解列表
PdfDocumentAttachmentAnnotation[] annotations = this.pdfDocumentViewer1.GetAttachmentAnnotaions();
if (annotations != null && annotations.Length > )
{
//注解属性
for (int i = ; i < annotations.Length; i++)
{
PdfDocumentAttachmentAnnotation annotation = annotations[i];
ListViewItem item = new ListViewItem(annotation.FileName);
item.SubItems.Add(annotation.Text);
item.SubItems.Add(annotation.PageIndex.ToString());
item.SubItems.Add(annotation.Location.ToString());
item.Tag = annotation;
this.listView1.Items.Add(item);
}
} }
}
/// <summary>
/// 转到注解
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void listView1_Click(object sender, EventArgs e)
{
if (this.m_isAttachmentAnnotation)
{
PdfDocumentAttachmentAnnotation annotation = (PdfDocumentAttachmentAnnotation)this.listView1.SelectedItems[].Tag;
this.pdfDocumentViewer1.GotoAttachmentAnnotation(annotation);
}
}
最后的效果:
缺点:经过无数个文档加载测试发现某些pdf文档加载问题,如下
某pdf软件加载某文档
Spire.PdfViewer加载的某文档
源码下载:http://download.csdn.net/detail/oyipiantian/8683459
最新文章
- bash 相关的一些小代码片断
- ext3,ext4,xfs和btrfs文件系统性能对比
- 如何在多模型的情况下进行EF6的结构迁移
- Ubuntu 16.04 TensorFlow CPU 版本安装
- jQuery之DOM操作
- 容斥原理——uva 10325 	The Lottery
- jQuery(二)
- 遍历INI文件和删除指定域内容
- 浅谈Nginx负载均衡原理与实现
- git操作大全
- 20164318 毛瀚逸 Exp4 恶意代码分析
- 【原创】驱动加载之CreateService
- ajax---获取XMLHttpReuquest 对象
- iframe调用父页面函数用法举例
- Node.js学习笔记(5)--文件简单操作
- CentOS 7 打开关闭FirewallD防火墙端口命令
- Android textview及其子类
- Aviator 表达式求值引擎开源框架
- Windows 安装配置memcached+php的教程,以及相关资源下载
- Windows环境双系统安装环境配置
热门文章
- python webdriver中对不同下拉框通过文本值的选择
- Redis构建处理海量数据的大型购物网站
- 03Del.ashx(删除班级)
- CH5E09 能量相连【区间DP】
- HTTPS握手
- Python开发【笔记】:为什么pymysql重连后才能查到新添加的数据
- CSRF攻击详解(转)
- UChome Feed 机制
- (1.5)DML增强功能-try catch及事务控制
- centos LAMP第四部分mysql操作 忘记root密码 skip-innodb 配置慢查询日志 mysql常用操作 mysql常用操作 mysql备份与恢复 第二十二节课