C#显示PDF文件 | 您所在的位置:网站首页 › winform中预览pdf › C#显示PDF文件 |
拖一个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 |
CopyRight 2018-2019 实验室设备网 版权所有 |