Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a PDF Viewer from Adobe Reader and I have created setup file and installed to the machine and all pdf files are looks like my viewer icon.

My problem is, once open a pdf file from double click, pdf is not view, only the program is opening. Kindly see below my full code and please advise? Thanks!

C#
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)
        {

        }
    }
}
Posted

1 solution

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[^]
 
Share this answer
 
v2
Comments
abdulsafran 16-Nov-12 11:47am    
Hi Christian Graus, can you provide sample code for that? It would really help for me. Thanks!
Christian Graus 16-Nov-12 11:49am    
Added a link to my answer. By the way, if you gave me a 1 vote, that is a bad vote. The correct vote if I helped you, is 5.
abdulsafran 16-Nov-12 12:01pm    
Hey Christian, sorry for the vote, it's a mistake, just now i have voted you with full votes. Thanks for your support and if there are any concern I'll get back to you. Thanks again.
Christian Graus 16-Nov-12 12:05pm    
np, I don't normally trawl for votes, but you've confirmed my suspicion that there are people who assume that a 1 vote is a good vote :-)
abdulsafran 16-Nov-12 12:19pm    
Christian, I have checked the provided link, but still trouble me to how to get to the axAcroPDF1.LoadFile(); the correct path, can you advise with better code? Also, what is args in default?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900