unit u_op_seae_paper_getpages; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, OleServer, PDFTool_TLB, OleCtrls, PDFActiveXLib_TLB, ExtCtrls; type Tfrm_u_op_seae_paper_getpages = class(TForm) pdfctvx1: TPDFActiveX; pnl1: TPanel; procedure FormCreate(Sender: TObject); procedure ToOpenFile(strpath:string); procedure FormClose(Sender: TObject; var Action: TCloseAction); private { Private declarations } public { Public declarations } function GetPDFPages(strpath:string):Integer; end; var frm_u_op_seae_paper_getpages: Tfrm_u_op_seae_paper_getpages; implementation {$R *.dfm} procedure Tfrm_u_op_seae_paper_getpages.FormCreate(Sender: TObject); begin //IntToStr( pdfpgtl1.GetPdfPage(path)); end; procedure Tfrm_u_op_seae_paper_getpages.ToOpenFile(strpath:string); begin pdfctvx1.FPDF_OpenFile(strpath,'') ; end; function Tfrm_u_op_seae_paper_getpages.GetPDFPages(strpath:string):Integer; begin Result:=- 1 ; try if(FileExists(strpath) ) then begin ToOpenFile(strpath); Result:= pdfctvx1.FPDF_GetPageCount; //pdfctvx1.FPDF_CloseFile (); if(Result<=0) then showmessage(strpath+'获取页数失败!'); end else showmessage(strpath+'不存在或者不可访问!'); except end; end; procedure Tfrm_u_op_seae_paper_getpages.FormClose(Sender: TObject; var Action: TCloseAction); begin // pdfctvx1. FPDF_ExitAppActiveX (); end; end.