日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

c#pdf查看器

發布時間:2023/12/19 综合教程 37 生活家
生活随笔 收集整理的這篇文章主要介紹了 c#pdf查看器 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

FreeSpire.PDF for .NETis aCommunity Editionof theSpire.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-iceblueSpire.PdfViewer-FEBin下的相應版本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, 1);
            this.m_isAttachmentAnnotation = true;
            this.listView1.Visible = true;
            this.listView1.Items.Clear();
            this.listView1.Columns.Clear();
            if (this.pdfDocumentViewer1.IsDocumentLoaded && this.pdfDocumentViewer1.PageCount > 0)
            {
                this.listView1.View = View.Details;
                this.listView1.Columns.Add("注解",200);
                this.listView1.Columns.Add("內容",180);
                this.listView1.Columns.Add("頁碼",80);
                this.listView1.Columns.Add("位置",160);
                //獲取pdf注解列表
                PdfDocumentAttachmentAnnotation[] annotations = this.pdfDocumentViewer1.GetAttachmentAnnotaions();
                if (annotations != null && annotations.Length > 0)
                {
                    //注解屬性
                    for (int i = 0; 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[0].Tag;
                this.pdfDocumentViewer1.GotoAttachmentAnnotation(annotation);
            }
        }

最后的效果:

缺點:經過無數個文檔加載測試發現某些pdf文檔加載問題,如下

某pdf軟件加載某文檔

Spire.PdfViewer加載的某文檔

源碼下載:http://download.csdn.net/detail/oyipiantian/8683459

總結

以上是生活随笔為你收集整理的c#pdf查看器的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。