C#PDF查看器-如何加载 [英] C# PDF Viewer - How to load

查看:539
本文介绍了C#PDF查看器-如何加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从Adobe Reader创建了PDF Viewer,并且已经创建了安装文件并将其安装到机器上,并且所有pdf文件都看起来像我的查看器图标.

我的问题是,一旦双击打开一个pdf文件,就无法查看pdf,而只能打开该程序.请在下面查看我的完整代码,并请指教?谢谢!

 使用系统;
使用 System.Collections.Generic;
使用 System.ComponentModel;
使用 System.Data;
使用使用System.Drawing;
使用 System.Linq;
使用 System.Text;
使用使用System.Windows.Forms;
使用 System.IO;

命名空间 QUICK_PDF_VIEWER_V2008
{
    公共 部分  class  Form1:表单
    {
        公共 Form1()
        {
            InitializeComponent();
        }

        私有 无效 openToolStripMenuItem_Click(对象发​​件人,EventArgs e)
        {
            OpenFileDialog open =  OpenFileDialog();
            open.Title = " ;
            open.Filter = " ;

            尝试
            {
                如果(open.ShowDialog()== System.Windows.Forms.DialogResult.OK)
                {
                    axAcroPDF1.LoadFile(open.FileName);

                }

            }
            捕获(例如,ArgumentException)
            {
                MessageBox.Show(ex.Message.ToString()," ,MessageBoxButtons.OK,MessageBoxIcon.错误);

            }
            捕获(例外)
            {
                MessageBox.Show(ex.Message.ToString()," ,MessageBoxButtons.OK,MessageBoxIcon.错误);
            }
        }

        私有 无效 aboutUsToolStripMenuItem_Click(对象发​​件人,EventArgs e)
        {
            MessageBox.Show("  ",MessageBoxButtons.OK,MessageBoxIcon.Information);
        }

        私有 无效 axAcroPDF1_OnError(对象发​​件人,EventArgs e)
        {

        }

        私有 无效 Form1_Load(对象发​​件人,EventArgs e)
        {

        }
    }
} 

解决方案

这里没有代码可以处理该问题.如果您通过将文件与文件关联后双击打开了文件,则启动此窗口的代码起始代码将传递参数.您需要读取这些参数并传递文件路径,以便此代码自动打开它.

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; namespace QUICK_PDF_VIEWER_V2008 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog open = new OpenFileDialog(); open.Title = "Open"; open.Filter = "All File|*.*"; try { if (open.ShowDialog() == System.Windows.Forms.DialogResult.OK) { axAcroPDF1.LoadFile(open.FileName); } } catch (ArgumentException ex) { MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void aboutUsToolStripMenuItem_Click(object sender, EventArgs e) { MessageBox.Show("This is a Product of Adobe, Thanks", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void axAcroPDF1_OnError(object sender, EventArgs e) { } private void Form1_Load(object sender, EventArgs e) { } } }

解决方案

There is no code here to handle that. your code starting code which launches this window, is passed arguments if you opened the file by double clicking after associating it with the file. You need to read those arguments and pass the file path through so that this code auto opens it.

Here[^]


这篇关于C#PDF查看器-如何加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆