Page 1 of 1

PDF Viewer

Posted: Mon Nov 11, 2013 1:18 pm
by daoa80
Is there an option on not to use the open file from the PDF Viewer and instead use a custom button to open the specified file directly?


button 1 open x.pdf file
button 2 open x2.pdf file and so on?

In that way I do not get the prompt box for what doc I want to open.


Thnaks

Re: PDF Viewer

Posted: Mon Nov 11, 2013 3:33 pm
by stuartm
Please check out this msdn resouce as well:

http://msdn.microsoft.com/en-us/library ... 10%29.aspx

1) Create a button on the canvas
2) Place the PDFViewer on the canvas
3) Click on the Script Tab
4) Write an event handler for your button(see code below)

void Button1_Click(System.Object sender, System.EventArgs e)
{
OpenFileDialog fd = new OpenFileDialog();

if(fd.ShowDialog() == DialogResult.OK) {
PDFViewer1.FileName = fd.FileName;
}

}

Re: PDF Viewer

Posted: Mon Nov 11, 2013 4:34 pm
by daoa80
Thanks for the feedback. But it looks like OpenFileDialog is the same as clicking on the open button from the PDFViewer and selecting a file. The idea is to click on the custom button an automatically open the pdf file using the PDFViewer w/o selecting a file from a list.

Thanks

Re: PDF Viewer

Posted: Mon Nov 11, 2013 4:49 pm
by daoa80
I got it. Thanks for your help.

Re: PDF Viewer

Posted: Wed Mar 30, 2016 1:12 am
by aperez
Hi,

I need to open a PDF file from a button and I tried the example of stuartm but it didnĀ“t work.
Why did you choose PDFViewer1 ?

I can see in my script PDFViewer without 1 and I put Variadorabb instead of Filename because my file has this name.

void Button26_Click(System.Object sender, System.EventArgs e)
{
OpenFileDialog fd = new OpenFileDialog();

if(fd.ShowDialog() == DialogResult.OK)
{
PDFViewer.Variadorabb = fd.Variadorabb;
}
}

Regards.
Antonio