Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# PDF
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!
 
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 16-Nov-12 6:22am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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[^]
  Permalink  
v2
Comments
abdulsafran at 16-Nov-12 11:47am
   
Hi Christian Graus, can you provide sample code for that? It would really help for me. Thanks!
Christian Graus at 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 at 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 at 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 at 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?
abdulsafran at 16-Nov-12 12:46pm
   
Working, thanks Christian.

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

  Print Answers RSS
0 OriginalGriff 384
1 Maciej Los 290
2 Sergey Alexandrovich Kryukov 230
3 CPallini 170
4 Shweta N Mishra 165
0 OriginalGriff 7,760
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,785


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 16 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100