且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在指定目的地以编程方式打开 pdf 文件

更新时间:2022-11-05 15:45:45

我使用如下代码:

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);

注意参数中的/n".它使 Adob​​e 始终打开一个新文档.否则,如果文档已经打开,它不会将它移动到正确的命名目的地.这取决于您希望应用程序的行为.

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.