C#显示PDF文件

论坛 期权论坛 脚本     
已经匿名di用户   2022-7-2 21:50   3444   0

拖一个Adobe PDF ReaderC#显示PDF文件到窗体上, 双击窗体, 在窗体加载时, 弹出对话框, 加载PDFC#显示PDF文件
string fileName = MyOpenFileDialog();
axAcroPDF1.LoadFile(fileName);

MyOpenFileDialog()C#显示PDF文件为:
string MyOpenFileDialog()
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "PDF文档(*.pdf)|*.pdf";

if (ofd.ShowDialog() == DialogResult.OK)
{
return ofd.FileName;
}
else
{
return null;
}
}

C#显示PDF文件C#显示PDF文件创建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);

不过要注意, 在C#显示PDF文件们把Adobe PDF Reader组件拖到窗体上白勺时候, 它会自动引用2个dll:AcroPDFLib和AcroPDFLib

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:81
帖子:4969
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP