c#pdf查看器

來源:互聯網
上載者:User

標籤:

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, 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查看器

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.