Skip to main content
January 11, 2016
Question

Acrobat DC ActiveX crashes

  • January 11, 2016
  • 0 replies
  • 717 views

In a very simple Delphi program that holds an instance of TAcroPDF, if I set the .src property to a file, all is well and the pdf displays in my application.

However if I call any procedure on the ActiveX control (I've tried LoadFile, Print, PrintWithDialog, GotoNextPage, GotoPreviousPage) then the application crashes after closing. This even happens if I call a procedure without loading a file. And calling Free() on the ActiveX control also throws an exception.

The program code hasn't changed. The only difference is installing Adobe Reader DC ActiveX (version X and XI worked fine for years). I have tested this on another computer to confirm. As soon as Adobe Reader DC is installed, the problem starts.

(If I put the ActiveX control in a Visual C# program it's fine. This seems to be limited to Delphi.)

The error is:

Exception EAccessViolation in module xxx.exe at 51F04CE6.

Access violation at address 51F05CE6. Read of address 51F05CE6.

Code below:

unit Unit1;

interface

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls, OleCtrlsAdobe, AcroPDFLib_TLB;

type

  TForm1 = class(TForm)

    AcroPDF1: TAcroPDF;

    btnLoadFile: TButton;

    btnPrint: TButton;

    btnPrintDialog: TButton;

    btnNext: TButton;

    btnPrev: TButton;

    btnSetSrc: TButton;

    btnExit: TButton;

    procedure btnLoadFileClick(Sender: TObject);

    procedure btnPrintClick(Sender: TObject);

    procedure btnPrintDialogClick(Sender: TObject);

    procedure btnNextClick(Sender: TObject);

    procedure btnPrevClick(Sender: TObject);

    procedure btnSetSrcClick(Sender: TObject);

    procedure btnExitClick(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

var

  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.btnLoadFileClick(Sender: TObject);

begin

   AcroPDF1.LoadFile('<filename goes here>'); // exception on close

   AcroPDF1.Setfocus;

end;

procedure TForm1.btnPrintClick(Sender: TObject);

begin

   AcroPDF1.Print; // exception on close

end;

procedure TForm1.btnPrintDialogClick(Sender: TObject);

begin

   AcroPDF1.PrintWithDialog; // exception on close

end;

procedure TForm1.btnNextClick(Sender: TObject);

begin

   AcroPDF1.gotoNextPage; // exception on close

end;

procedure TForm1.btnPrevClick(Sender: TObject);

begin

   AcroPDF1.gotoPreviousPage; // exception on close

end;

procedure TForm1.btnSetSrcClick(Sender: TObject);

begin

   AcroPDF1.src := '<filename goes here>'; // no exception

   AcroPDF1.Setfocus;

end;

procedure TForm1.btnExitClick(Sender: TObject);

begin

   AcroPDF1.src := '';

   //FreeAndNil(AcroPDF1); // immediate exception

   //AcroPDF1.Free; // immediate exception

   Close;

end;

end.

/////////////////////////////////////////////////////////////

object Form1: TForm1

  Left = 0

  Top = 0

  Caption = 'Form1'

  ClientHeight = 300

  ClientWidth = 635

  Color = clBtnFace

  Font.Charset = DEFAULT_CHARSET

  Font.Color = clWindowText

  Font.Height = -11

  Font.Name = 'Tahoma'

  Font.Style = []

  OldCreateOrder = False

  DesignSize = (

    635

    300)

  PixelsPerInch = 96

  TextHeight = 13

  object AcroPDF1: TAcroPDF

    Left = 8

    Top = 100

    Width = 619

    Height = 192

    Anchors = [akLeft, akTop, akRight, akBottom]

    TabOrder = 6

    ControlData = {000C0000FA3F0000D8130000}

  end

  object btnLoadFile: TButton

    Left = 16

    Top = 8

    Width = 75

    Height = 25

    Caption = 'LoadFile'

    TabOrder = 0

    OnClick = btnLoadFileClick

  end

  object btnPrint: TButton

    Left = 16

    Top = 39

    Width = 75

    Height = 25

    Caption = 'Print'

    TabOrder = 2

    OnClick = btnPrintClick

  end

  object btnPrintDialog: TButton

    Left = 97

    Top = 39

    Width = 75

    Height = 25

    Caption = 'Print Dialog'

    TabOrder = 3

    OnClick = btnPrintDialogClick

  end

  object btnNext: TButton

    Left = 340

    Top = 32

    Width = 75

    Height = 25

    Caption = 'Next'

    TabOrder = 5

    OnClick = btnNextClick

  end

  object btnPrev: TButton

    Left = 259

    Top = 32

    Width = 75

    Height = 25

    Caption = 'Prev'

    TabOrder = 4

    OnClick = btnPrevClick

  end

  object btnSetSrc: TButton

    Left = 97

    Top = 8

    Width = 75

    Height = 25

    Caption = 'Set Src (Ok)'

    TabOrder = 1

    OnClick = btnSetSrcClick

  end

  object btnExit: TButton

    Left = 552

    Top = 8

    Width = 75

    Height = 25

    Caption = 'Exit'

    TabOrder = 7

    OnClick = btnExitClick

  end

end

This topic has been closed for replies.