拖一个Adobe PDF Reader
到窗体上, 双击窗体, 在窗体加载时, 弹出对话框, 加载PDF
:
string fileName = MyOpenFileDialog();
axAcroPDF1.LoadFile(fileName);
MyOpenFileDialog()
为:
string MyOpenFileDialog()
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "PDF文档(*.pdf)|*.pdf";
if (ofd.ShowDialog() == DialogResult.OK)
{
return ofd.FileName;
}
else
{
return null;
}
}
也
用
创建Adobe PDF Reader组件:
string fileName = MyOpenFileDialog();
AxAcroPDFLib.AxAcroPDF axAcroPDF = new AxAcroPDFLib.AxAcroPDF();
axAcroPDF.Location = new System.Drawing.Point(0, 24);
axAcroPDF.Size = new System.Drawing.Size(292, 242);
axAcroPDF.Dock = DockStyle.Fill;
Controls.Add(axAcroPDF);
axAcroPDF.LoadFile(fileName);
不过要注意, 在
们把Adobe PDF Reader组件拖到窗体上白勺时候, 它会自动引用2个dll:AcroPDFLib和AcroPDFLib