tags:

views:

45

answers:

3

I successfully added AcroPDF in my application. When a PDF needs to be displayed I create an instance of AcroPDF dynamically and insert it into a TPanel with align set to alClient. My problem is that when the Form/Panel is resized the AcroPDF does not follow. Only if a new file is loaded. I tried several solutions to no avail. What should I do?

A: 

Have a look of EzPDFlibrary PDF SDK, it can display PDF without Acrobat /AcroPDF.

Sarah
AcroPDF does what I need. No need to purchase a third-party library if Adobe already provides what I want.
Eduardo Mauro
+1  A: 

It's a problem with recent versions of the Adobe OCX control, which you can work around by refocusing the control. In a preview dialog I have (which has an embedded, client-aligned AcroPdf control) I use the following OnResize handler for the form:

if Visible and (fPreviewV7 <> nil) then begin
  FocusControl(nil);
  FocusControl(fPreviewV7);
end;
mghie
Great!! Thank you very much.
Eduardo Mauro
+1  A: 

If you use ActiveX from version 9 of Acrobat Reader try this code in OnResize event of TPanel:

procedure TForm.PanelResize(Sender: TObject);
var
  rc: TRect;
  h: THandle;
begin
  if Assigned(AcroPdf) then
  begin
    if (Windows.GetClientRect(AcroPdf.Handle, rc)) then
    begin
      h := Windows.FindWindowEx(AcroPdf.Handle, 0, PChar('Static'), nil);
      if (h <> 0) then
        Windows.MoveWindow(h, 0, 0, rc.Right - rc.Left, rc.Bottom - rc.Top, True);
    end;
  end;
end;

The problem in that the child window of main AcroPdf window is not resized. So we found it by it's class name "Static" and manually move it to fill whole parent window. This code can not work on other versions of Acrobat Reader, because the window hierarchy and class name's may differ.

Schnider