//Advanced Delphi Systems Code: ads_AcroExch_PDDoc
unit ads_AcroExch_PDDoc;
{Copyright(c)2016 Advanced Delphi Systems

 Richard Maley
 Advanced Delphi Systems
 12613 Maidens Bower Drive
 Potomac, MD 20854 USA
 phone 301-840-1554
 dickmaley@advdelphisys.com

 The code herein can be used or modified by anyone.  Please retain references
 to Richard Maley at Advanced Delphi Systems.  If you make improvements to the
 code please send your improvements to dickmaley@advdelphisys.com so that the
 entire Delphi community can benefit.  All comments are welcome.
}
(*
UnitIndex Master Index Implementation Section Download Units
Description: ads_AcroExch_PDDoc.pas
This unit contains the following routines.

Register   TAcroExch_PDDoc.AcquirePage   TAcroExch_PDDoc.ClearFlags   TAcroExch_PDDoc.Close   TAcroExch_PDDoc.CreatePDDoc   TAcroExch_PDDoc.CreateTextSelect  TAcroExch_PDDoc.CreateThumbs   TAcroExch_PDDoc.CropPages   TAcroExch_PDDoc.DeletePages   TAcroExch_PDDoc.DeleteThumbs   TAcroExch_PDDoc.GetFileName   TAcroExch_PDDoc.GetFlags   TAcroExch_PDDoc.GetInfo   TAcroExch_PDDoc.GetInstanceID   TAcroExch_PDDoc.GetJSObject   TAcroExch_PDDoc.GetNumPages   TAcroExch_PDDoc.GetPageMode   TAcroExch_PDDoc.GetPermanentID   TAcroExch_PDDoc.InsertPages   TAcroExch_PDDoc.MovePage   TAcroExch_PDDoc.Open   TAcroExch_PDDoc.OpenAVDoc   TAcroExch_PDDoc.ReplacePages   TAcroExch_PDDoc.Save   TAcroExch_PDDoc.SetFlags   TAcroExch_PDDoc.SetInfo   TAcroExch_PDDoc.SetOpenInfo   TAcroExch_PDDoc.SetPageMode  

*)
interface
Uses
  Acrobat_TLB, Classes;

Type
  TAcroExch_PDDoc = class(TComponent)
  Private
    FAcroExch_PDDoc : Variant;
  Public
    constructor Create(AOwner: TComponent); override;
    destructor  Destroy; override;
    function    AcquirePage(nPage: Integer): IDispatch;
    function    ClearFlags(nFlags: Integer): Integer; 
    function    Close: Integer;
    function    CreatePDDoc: Integer;
    function    CreateTextSelect(nPage: Integer; const iAcroRect: IDispatch): IDispatch;
    function    CreateThumbs(nFirstPage: Integer; nLastPage: Integer): Integer;
    function    CropPages(nStartPage: Integer; nEndPage: Integer; nOddOrEvenPagesOnly: Smallint;const iAcroRect: IDispatch): Integer;
    function    DeletePages(nStartPage: Integer; nEndPage: Integer): Integer;
    function    DeleteThumbs(nStartPage: Integer; nEndPage: Integer): Integer;
    function    GetFileName: WideString;
    function    GetFlags: Integer; 
    function    GetInfo(const szInfoKey: WideString): WideString;
    function    GetInstanceID: WideString;
    function    GetJSObject: IDispatch;
    function    GetNumPages: Integer;
    function    GetPageMode: Integer;
    function    GetPermanentID: WideString;
    function    InsertPages(nInsertPageAfter: Integer; const iPDDocSource: IDispatch;nStartPage: Integer; nNumPages: Integer; bBookmarks: Integer): Integer;
    function    MovePage(nMoveAfterThisPage: Integer; nPageToMove: Integer): Integer;
    function    Open(const szFullPath: WideString): Integer;
    function    OpenAVDoc(const szTempTitle: WideString): IDispatch;
    function    ReplacePages(nStartPage: Integer; const iPDDocSource: IDispatch;nStartSourcePage: Integer; nNumPages: Integer;bMergeTextAnnotations: Integer): Integer;
    function    Save(nType: Smallint; const szFullPath: WideString): Integer;
    function    SetFlags(nFlags: Integer): Integer;
    function    SetInfo(const szInfoKey: WideString; const szBuffer: WideString): Integer;
    function    SetOpenInfo(pgNum: Integer; viewMode: Smallint; const magnification: WideString): Integer;
    function    SetPageMode(nPageMode: Integer): Integer;
  End;

procedure Register;

implementation

Uses
  Variants, ComObj;

//
Unit Description UnitIndex Master Index
procedure Register;
begin
  RegisterComponents('Acrobat', [TAcroExch_PDDoc]);
end;

constructor TAcroExch_PDDoc.Create(AOwner: TComponent);
begin
  inherited;
  FAcroExch_PDDoc := CreateOleObject('AcroExch.PDDoc');
end;

destructor TAcroExch_PDDoc.Destroy;
begin
  FAcroExch_PDDoc := unassigned;
  inherited;
end;

//
Unit Description UnitIndex Master Index
function TAcroExch_PDDoc.CreatePDDoc: Integer;
begin
  Result := FAcroExch_PDDoc.Create;
end;

//
Unit Description UnitIndex Master Index
function TAcroExch_PDDoc.CreateTextSelect(nPage: Integer;const iAcroRect: IDispatch): IDispatch;
begin
  Result := FAcroExch_PDDoc.CreateTextSelect(nPage,iAcroRect);
end;

//
Unit Description UnitIndex Master Index
function TAcroExch_PDDoc.CreateThumbs(nFirstPage,nLastPage: Integer): Integer;
begin
  Result := FAcroExch_PDDoc.CreateThumbs(nFirstPage,nLastPage);
end;

//
Unit Description UnitIndex Master Index
function TAcroExch_PDDoc.CropPages(nStartPage, nEndPage: Integer;nOddOrEvenPagesOnly: Smallint; const iAcroRect: IDispatch): Integer;
begin
  Result := FAcroExch_PDDoc.CropPages(nStartPage,nEndPage,nOddOrEvenPagesOnly,iAcroRect);
end;

//
Unit Description UnitIndex Master Index
function TAcroExch_PDDoc.DeletePages(nStartPage,nEndPage: Integer): Integer;
begin
  Result := FAcroExch_PDDoc.DeletePages(nStartPage,nEndPage);
end;

//
Unit Description UnitIndex Master Index
function TAcroExch_PDDoc.DeleteThumbs(nStartPage,nEndPage: Integer): Integer;
begin
  Result := FAcroExch_PDDoc.DeleteThumbs(nStartPage,nEndPage);
end;

//
Unit Description UnitIndex Master Index
function TAcroExch_PDDoc.AcquirePage(nPage: Integer): IDispatch;
begin
  Result := FAcroExch_PDDoc.AcquirePage(nPage);
end;

//
Unit Description UnitIndex Master Index
function TAcroExch_PDDoc.ClearFlags(nFlags: Integer): Integer;
begin
  Result := FAcroExch_PDDoc.ClearFlags(nFlags);
end;

//
Unit Description UnitIndex Master Index
function TAcroExch_PDDoc.Close: Integer;
begin
  Result := FAcroExch_PDDoc.Close;
end;

//
Unit Description UnitIndex Master Index
function TAcroExch_PDDoc.GetFileName: WideString;
begin
  Result := FAcroExch_PDDoc.GetFileName;
end;

//
Unit Description UnitIndex Master Index
function TAcroExch_PDDoc.GetFlags: Integer;
begin
  Result := FAcroExch_PDDoc.GetFlags;
end;

//
Unit Description UnitIndex Master Index
function TAcroExch_PDDoc.GetInfo(const szInfoKey: WideString): WideString;
begin
  Result := FAcroExch_PDDoc.GetInfo(szInfoKey);
end;

//
Unit Description UnitIndex Master Index
function TAcroExch_PDDoc.GetInstanceID: WideString;
begin
  Result := FAcroExch_PDDoc.GetInstanceID;
end;

//
Unit Description UnitIndex Master Index
function TAcroExch_PDDoc.GetJSObject: IDispatch;
begin
  Result := FAcroExch_PDDoc.GetJSObject;
end;

//
Unit Description UnitIndex Master Index
function TAcroExch_PDDoc.GetNumPages: Integer;
begin
  Result := FAcroExch_PDDoc.GetNumPages;
end;

//
Unit Description UnitIndex Master Index
function TAcroExch_PDDoc.GetPageMode: Integer;
begin
  Result := FAcroExch_PDDoc.GetPageMode;
end;

//
Unit Description UnitIndex Master Index
function TAcroExch_PDDoc.GetPermanentID: WideString;
begin
  Result := FAcroExch_PDDoc.GetPermanentID;
end;

//
Unit Description UnitIndex Master Index
function TAcroExch_PDDoc.InsertPages(nInsertPageAfter: Integer;const iPDDocSource: IDispatch; nStartPage, nNumPages,  bBookmarks: Integer): Integer;
begin
  Result := FAcroExch_PDDoc.InsertPages(nInsertPageAfter,iPDDocSource,nStartPage,nNumPages, bBookmarks);
end;

//
Unit Description UnitIndex Master Index
function TAcroExch_PDDoc.MovePage(nMoveAfterThisPage,nPageToMove: Integer): Integer;
begin
  Result := FAcroExch_PDDoc.MovePage(nMoveAfterThisPage,nPageToMove);
end;

//
Unit Description UnitIndex Master Index
function TAcroExch_PDDoc.Open(const szFullPath: WideString): Integer;
begin
  Result := FAcroExch_PDDoc.Open(szFullPath);
end;

//
Unit Description UnitIndex Master Index
function TAcroExch_PDDoc.OpenAVDoc(const szTempTitle: WideString): IDispatch;
begin
  Result := FAcroExch_PDDoc.OpenAVDoc(szTempTitle);
end;

//
Unit Description UnitIndex Master Index
function TAcroExch_PDDoc.ReplacePages(nStartPage: Integer;const iPDDocSource: IDispatch; nStartSourcePage, nNumPages,  bMergeTextAnnotations: Integer): Integer;
begin
  Result := FAcroExch_PDDoc.ReplacePages(nStartPage,iPDDocSource,nStartSourcePage,nNumPages,bMergeTextAnnotations);
end;

//
Unit Description UnitIndex Master Index
function TAcroExch_PDDoc.Save(nType: Smallint;const szFullPath: WideString): Integer;
begin
  Result := FAcroExch_PDDoc.Save(nType,szFullPath);
end;

//
Unit Description UnitIndex Master Index
function TAcroExch_PDDoc.SetFlags(nFlags: Integer): Integer;
begin
  Result := FAcroExch_PDDoc.SetFlags(nFlags);
end;

//
Unit Description UnitIndex Master Index
function TAcroExch_PDDoc.SetInfo(const szInfoKey,szBuffer: WideString): Integer;
begin
  Result := FAcroExch_PDDoc.SetInfo(szInfoKey,szBuffer);
end;

//
Unit Description UnitIndex Master Index
function TAcroExch_PDDoc.SetOpenInfo(pgNum: Integer; viewMode: Smallint;const magnification: WideString): Integer;
begin
  Result := FAcroExch_PDDoc.SetOpenInfo(pgNum,viewMode,magnification);
end;

//
Unit Description UnitIndex Master Index
function TAcroExch_PDDoc.SetPageMode(nPageMode: Integer): Integer;
begin
  Result := FAcroExch_PDDoc.SetPageMode(nPageMode);
end;

end.
//