简体   繁体   English

使用C#Visual Studio转到PDF中的特定页面

[英]Goto specific page in PDF using C# Visual Studio

i'm using the AxAcroPDFLib.AxAcroPDF Tool from the toolbox and am having it a specific PDF when i click a button. 我正在使用工具箱中的AxAcroPDFLib.AxAcroPDF工具,当我单击一个按钮时,它具有特定的PDF。 I have a separate button (button2) and Textbox which i want to use to automatically move the PDF page to the page number entered into the TextBox when button2 is pressed. 我有一个单独的按钮(button2)和文本框,我想使用它们来自动将PDF页面移动到按下button2时输入到TextBox中的页码。

The following code isn't working and i'm not sure what code to use to get it to work (and no i cannot just use the tools inside the PDF reader to do this as i need all the controls on monitor 1 and the PDF is displayed on Montior 2, i've sorted this part): 以下代码无法正常工作,我不确定要使用什么代码才能正常工作(不,我不能仅使用PDF阅读器中的工具来执行此操作,因为我需要监视器1和PDF上的所有控件显示在Montior 2上,我已经对此部分进行了排序):

KEY: dsm = form2 | 密钥:dsm = form2 | pdfview = the PDF reader inside form2 pdfview = form2内部的PDF阅读器

dsm.pdfview.setCurrentPage(TextBox1.Text);

This isn't working. 这不起作用。 i've also tried: 我也尝试过:

dsm.pdfview.setCurrentPage = TextBox1.Text;

Also not working. 也行不通。 Any help would be great! 任何帮助将是巨大的! Thanks. 谢谢。

The documentation clearly shows that the syntax is void setCurrentPage(LONG nPage) 该文档清楚地表明该语法无效setCurrentPage(LONG nPage)

You are passing a string in. You need to parse your string into an int or long before passing it in. 您正在传递一个字符串。您需要将字符串解析为一个int或很长时间才能传递它。

How to parse a string into a number 如何将字符串解析为数字

Also, based on the documentation your original method call was correct except for you passed in a parameter of the wrong type. 此外,根据文档,您原始的方法调用是正确的,只是您传入了错误类型的参数。 Once you convert it, make that same call with the new parameter. 转换后,请使用新参数进行相同的调用。

Here's the documentation from Adobe 这是来自Adobe的文档

Here's what I did. 这就是我所做的。 Thanks to Dmitry for pointing me in the correct direction: 感谢Dmitry为我指出了正确的方向:

KEY: dsm = form2 | 密钥:dsm = form2 | pdfview = the Adobe PDF tool insterted into form2 pdfview =插入form2的Adobe PDF工具

private void srchPageNumBtn_Click(object sender, EventArgs e)
    {

        int nm = Int32.Parse(textBox2.Text);

       dsm.pdfview.setCurrentPage(nm);
    }

Works like a charm ;) 奇迹般有效 ;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM