I would like to open a PDF file at named destination using WinForms (C#). Here is my code:
System.Diagnostics.Process myProcess = new System.Diagnostics.Proc
I use the following code:
string strNamedDestination = "MyNamedDestination"; // Must be defined in PDF file.
string strFilePath = "MyFilePath.pdf";
string strParams = " /n /A \"pagemode=bookmarks&nameddest=" + strNamedDestination + "\" \"" + strFilePath + "\"";
Process.Start("AcroRd32.exe", strParams);
Note the "/n" inside the params. It makes Adobe to always open a new document. Otherwise, if the document was already opened, it doesn't move it to the right Named Destination. It depends on the behaviour you want for your application.
Have you set up the destinations? You need to be have the standard or professional versions of Adobe Acrobat in order to do this:
http://kb2.adobe.com/cps/317/317300.html
Adobe Reader has a few bugs regarding opening to named destinations. Take a look at http://xenon.arcticus.com/open-pdf-named-destination-dde-c-c for some information and workarounds.
I have a csv with 5 columns. Column1 contains PDF names and Column5 pagenumbers. The executable displays the csv. When I doubleclick on a line in the csv the following code is executed :
ListViewItem item = lvwItems.SelectedItems[0];
Process myProcess = new Process();
myProcess.StartInfo.FileName = "Acrobat.exe";
myProcess.StartInfo.Arguments = "/A page=" + item.SubItems[4].Text + " " + item.Text;
myProcess.Start();
This opens the selected PDF which name is in item.Text
on the page which pagenumber is in item.SubItems[4].Text
Regarding the Adobe documentation when opening a PDF document from a command shell, you can pass the parameters to the open command using the /A switch using the following syntax:
myProcess.StartInfo.Arguments = "/A \"nameddest=Test2=OpenActions\" C:\\example.pdf";
If I omit the OpenActions parameter everything works fine like:
myProcess.StartInfo.Arguments = "/A \"nameddest=Test2\" C:\\example.pdf";
I'm not sure why the OpenActions breaks opening the file but with omitting it works fine.