You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Delphi 11中添加并使用Adobe Acrobat ActiveX Reader的问题求助

Delphi内联显示PDF及AcroPDF控件面板不显示问题解决

一、解决AcroPDF控件未出现在组件面板的问题

  • 重新执行导入安装流程:打开Component菜单 → Import Component → 选择Import a Type Library,在列表里找到Adobe Acrobat Control for ActiveX(不同Reader版本名称可能略有差异),确认生成单元为AcroPDFLib.pas,勾选「Install component」,指定要安装到的组件面板(比如Win32),点击Install完成后重启Delphi。
  • 手动注册AcroPDF.dll:如果导入后控件仍不显示,大概率是系统内的控件未注册。以管理员身份打开命令提示符,执行注册命令(路径根据你的Reader版本调整,示例为DC版本路径):
    regsvr32 "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroPDF.dll"
    
    注册成功后重新导入安装控件。
  • 手动加载已生成的包:如果已生成AcroPDFLib.bpl但未加载到面板,打开Component → Install Packages,点击Add按钮,找到生成的bpl文件(一般在Delphi的Projects\Bpl目录或自定义输出目录),添加后勾选该包,重启Delphi即可。

二、实现ListBox选择PDF并内联显示

等控件能正常拖到窗体后,按以下步骤操作:

  1. 在窗体上拖放一个AcroPDF控件(命名为AcroPDF1)和一个ListBox控件(命名为ListBox1)。
  2. 加载指定目录的PDF文件到ListBox,示例代码写在Form的OnCreate事件中:
    procedure TForm1.FormCreate(Sender: TObject);
    var
      SearchRec: TSearchRec;
    begin
      // 替换为你的PDF存储目录
      if FindFirst('D:\ContactsPDF\*.pdf', faAnyFile, SearchRec) = 0 then
      begin
        repeat
          ListBox1.Items.Add(SearchRec.Name);
        until FindNext(SearchRec) <> 0;
        FindClose(SearchRec);
      end;
    end;
    
  3. 在ListBox的OnClick事件中处理文件打开逻辑:
    procedure TForm1.ListBox1Click(Sender: TObject);
    var
      FullPDFPath: string;
    begin
      if ListBox1.ItemIndex = -1 then Exit;
      // 拼接完整文件路径
      FullPDFPath := 'D:\ContactsPDF\' + ListBox1.Items[ListBox1.ItemIndex];
      AcroPDF1.LoadFile(FullPDFPath);
      // 可选设置:显示工具栏、适配页面显示
      AcroPDF1.setShowToolbar(True);
      AcroPDF1.setView('Fit');
    end;
    

注意事项

  • 确保用户电脑已安装Adobe Acrobat Reader DC(或兼容旧版本如XI),否则控件无法正常运行。
  • 打包应用时无需包含AcroPDF.dll,用户机器上的Reader会自带该文件。

内容的提问来源于stack exchange,提问作者Marcell

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 03:52:59