Question:
I'm trying to open a PDF document from a ListBox
with C #. I am able to load the documents that are in the file but it is not displayed in the axAcroPDF1
, what I want is to be able to load all the files to this ListBox
and to be able to select the one I want and have it shown to me in the axAcroPDF1
. Thanks in advance!!!
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
FolderBrowserDialog FBD = new FolderBrowserDialog();
if (FBD.ShowDialog() == DialogResult.OK)
{
FileName.Items.Clear();
string[] files = Directory.GetFiles(FBD.SelectedPath);
string[] dirs = Directory.GetDirectories(FBD.SelectedPath);
foreach (string file in files)
{
FileName.Items.Add(Path.GetFileName(file));
}
foreach (string dir in dirs)
{
FileName.Items.Add(Path.GetFileName((dir)));
}
}
}
private void FileName_SelectedIndexChanged(object sender, EventArgs e)
{
FileInfo file = (FileInfo)FileName.SelectedItem;
Process.Start(file.FullName);
}
private void axAcroPDF1_Enter(object sender, EventArgs e)
{
}
}
Answer:
You must call the Acrobat Reader executable
var p = new Process();
p.StartInfo.Arguments= @"C:\Temp\tests\bin\Debug\netcoreapp2.1\ElPDF.pdf";
p.StartInfo.FileName = @"C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe";
p.Start();