我有一个pdf查看器,为了这个例子,从一个列表框中显示选定的文件名。它是一个简单的表单,有一个列表框、一个axAcroPDF和textbox来确认正确的文件路径。代码如下所示,文件已放置在Debug文件夹中的pdfs文件夹中:
using System;
using System.Windows.Forms;
namespace pdf_viewer
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
string path = AppDomain.CurrentDomain.BaseDirectory + "pdfs\\" + listBox1.SelectedItem.ToString();
textBox1.Text = path;
InitializeAdobe(path);
}
private void InitializeAdobe(string filePath)
{
axAcroPDF1.LoadFile(filePath);
axAcroPDF1.src = filePath;
axAcroPDF1.setShowToolbar(false);
axAcroPDF1.setView("Fit");
axAcroPDF1.setLayoutMode("SinglePage");
axAcroPDF1.Show();
}
}
}所有这些都能正确地解决以下几个问题:
此外:
谢谢
PS自最初发布以来,我尝试在webBrowser窗口中显示,但在第二次选择条目时,工具栏面板显示的情况完全相同。守则如下:
webBrowser1.Url = new Uri(path);发布于 2020-06-13 23:03:18
在很长一段时间后重新讨论了这个问题,并在这里找到了答案,Disable Adobe Reader toolbar from my ActiveX
它似乎在axAcroPDF和webbrowser窗口中工作。对于axAcropdf,在不显示工具栏的情况下显示pdf的代码是(使用问题示例):
this.axAcroPDF1.src = filePath + "#toolbar=0";
this.axAcroPDF1.setView("Fit");
this.axAcroPDF1.setLayoutMode("SinglePage");
this.axAcroPDF1.Show();用于webbrowser窗口
InitializeAdobe(path);
webBrowser1.Url = new Uri(path + "#toolbar=0");https://stackoverflow.com/questions/40143598
复制相似问题