Kod: Tümünü seç
uses
ComObj, ActiveX,AcroPDFLib_TLB;
type
.
.
.
private
function IsOLEObjectInstalled(Name: string): Boolean;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
xAcrobat:TAcroPDF;
implementation
{$R *.dfm}
function TForm1.IsOLEObjectInstalled(Name: String): Boolean;
var
ClassID: TCLSID;
Rez: HRESULT;
begin
Rez := CLSIDFromProgID(PWideChar(WideString(Name)), ClassID);
Result := (Rez = S_OK);
end;
function EnumWindowProc(pHwnd: THandle; Edit: Integer): LongBool; stdcall;
function GetClassNameTxt(gcnHwnd: THandle): string;
var dWClassBuf: PChar;
begin
dWClassBuf := StrAlloc(1024);
GetClassName(gcnHwnd, dWClassBuf, 1024);
Result := dWClassBuf;
StrDispose(dWClassBuf);
end;
function GetWindowTxt(gwtHwnd: THandle): string;
var dWTextBuf: PChar;
TextLen: Integer;
begin
TextLen := SendMessage(gwtHwnd, WM_GetTextLength, 0, 0);;
dWTextBuf := StrAlloc(TextLen + 1);
SendMessage(gwtHwnd, WM_GetText, TextLen + 1, Integer(dWTextBuf));
Result := dWTextBuf;
StrDispose(dWTextBuf);
end;
begin
Result := LongBool(True);
if (GetClassNameTxt(pHwnd) = 'AVL_AVView') and (GetWindowTxt(pHwnd) = 'AVPageView') then
begin
TStatusBar(Edit).Panels[3].Text := GetWindowTxt(FindWindowEx(pHwnd, 0, 'RICHEDIT50W', nil));
Result := LongBool(False);
end;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
ac :TOpenDialog;
SayfaNo :OleVariant;
begin
StatusBar1.Panels[5].Text:='';
ac :=TOpenDialog.Create(Form1);
try
if ac.Execute then
Begin
xAcrobat.LoadFile(ac.FileName);
xAcrobat.setShowToolbar(True);
StatusBar1.Panels[5].Text:=ac.FileName;
if IsOLEObjectInstalled('AcroExch.PDDoc') then
Begin
SayfaNo := CreateOleObject('AcroExch.PDDoc');
SayfaNo.Open(ac.FileName);
StatusBar1.Panels[1].Text:=IntToStr( SayfaNo.GetNumPages);
End;
End;
finally
FreeAndNil(Ac);
end;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
EnumChildWindows(xAcrobat.Handle, @EnumWindowProc, LongInt(StatusBar1));
end;
procedure TForm1.BitBtn3Click(Sender: TObject);
begin
xAcrobat.setCurrentPage(StrToIntDef(Edit2.Text,1));
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var
s:Integer;
begin
s := xAcrobat.ControlInterface._AddRef;
xAcrobat.Src:= '';
xAcrobat.Free;
xAcrobat := Nil;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
xAcrobat := TAcroPDF.Create(Form1);
xAcrobat := TAcroPDF.Create(Form1);
xAcrobat.Parent := Form1;
xAcrobat.Align := alClient;
xAcrobat.Visible := True;
end;
end.
Yukarıda olduğu gibi
Kod: Tümünü seç
SayfaNo := CreateOleObject('AcroExch.PDDoc');
Şema kaynağı
Örnek Çalışma