Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.Process();
myProcess.StartInfo.FileName = "Acrobat.exe";
myProcess.StartInfo.Arguments = "/A "nameddest=Test2=OpenActions" C:\example.pdf";
myProcess.Start();

It always opens the file at page 1 even having the destination Test2 at page # 10. It basically ignores the destination parameter. However if I use another parameter like the page number it works fine. For example:

myProcess.StartInfo.Arguments = "/A "page=5=OpenActions" C:\example.pdf";

will always open the PDF document at page 5.

Thanks in advance for your help

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
210 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...