Click here to Skip to main content
15,922,894 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Dear friends,

I am looking forward to open a pdf file in a separate window automatically without selecting anay file. The file is saved in the same directory as bin\debug.

My code is:

C#
namespace Info
{
    public partial class documentationForm : Form
    {
        public documentationForm()
        {
            InitializeComponent();
        }

        private void documentationForm_Load(object sender, EventArgs e)
        {
            axAcroPDF1.src = openFileDialog.FileName; //("info.pdf");
        }
    }
}


is there any way to add the file name manually?

regards
AM
Posted
Comments
BillWoodruff 29-Dec-15 8:24am    
you have the filepath ? if so, what's stopping you from opening it ?
ZurdoDev 29-Dec-15 8:48am    
I'm with Bill. What is your question exactly?

Dear member ... u should look once below link. you will get the solution.

http://www.c-sharpcorner.com/UploadFile/hirendra_singh/how-to-show-pdf-file-in-C-Sharp
 
Share this answer
 
try this way...

Response.Write("");
Response.Write("window.open('../Inventory/pages/printableads.pdf', '_newtab');");
Response.Write("");
 
Share this answer
 
Comments
Thomas Daniels 29-Dec-15 9:12am    
This is ASP.NET, the asker is using Windows Forms.
Imtiyaz10 30-Dec-15 0:03am    
you can use System.Diagnostics.Process.Start as well as WIN32 ShellExecute function by means of interop, for opening PDF files using the default viewer:
//------------------------------------------
System.Diagnostics.Process.Start("SOMEAPP.EXE","Path/SomeFile.Ext");

[System.Runtime.InteropServices.DllImport("shell32. dll")]
private static extern long ShellExecute(Int32 hWnd, string lpOperation,
string lpFile, string lpParameters,
string lpDirectory, long nShowCmd);
You can use WebBrowser control to load PDF by passing file path to Navigate()

C#
private void OpenPdfInWebBrowser(string filePath)
{
    if (!string.IsNullOrWhiteSpace(filePath))
    {
        yourwebBrowser1.Navigate(@filePath);
    }
}


Source : open Pdf document in C# in Window application - Stack Overflow[^]

Good luck
 
Share this answer
 

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