Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
Member Area
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Become a Member
-Why sign up!
-Chat Online!
-Indexes NEW!!
-Build your resume
-Find a job
-Post a job
-Resume Search
-Link to us
Visit Embarcadero
Embarcadero Community
Read Adobe Acrobat PDF files from my application Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
Delphi 3.x
User Rating
# Votes
DSP, Administrator
Reference URL:
			Author: Jorge Abel Ayala Marentes

Adobe Acrobat PDF is a well known format that some users love, so how can I open 
PDF files from a Delphi Application?


Ok, you must have installed the Acrobat Reader program in your machine, if you 
donīt have it you can download it from Adobeīs site: 

After that you have to install the type library for Acrobat (Project -> Import Type 
Library from Delphiīs menu) select "Acrobat Control for ActiveX (version x)". Where 
x stands for the current version of the type library. Click the install button to 
install it into the IDE. 

Now, Start a new Application, drop from whatever page of the component palette you 
have installed a TPDF component in a form, next add an OpenDialog, and finally a 
Button, in the Onclick event of the Button use: 

1   procedure TForm1.Button1Click(Sender: TObject);
2   begin
3     if OpenDialog1.Execute then
4       pdf1.src := OpenDialog1.FileName;
5   end;
7   //in PdfLib_TLB Unit you can find the interface of the TPdf class in order to know 
8   the behaviour of that class so here it is: 
10  TPdf = class(TOleControl)
11  private
12    FIntf: _DPdf;
13    function GetControlInterface: _DPdf;
14  protected
15    procedure CreateControl;
16    procedure InitControlData; override;
17  public
18    function LoadFile(const fileName: WideString): WordBool;
19    procedure setShowToolbar(On_: WordBool);
20    procedure gotoFirstPage;
21    procedure gotoLastPage;
22    procedure gotoNextPage;
23    procedure gotoPreviousPage;
24    procedure setCurrentPage(n: Integer);
25    procedure goForwardStack;
26    procedure goBackwardStack;
27    procedure setPageMode(const pageMode: WideString);
28    procedure setLayoutMode(const layoutMode: WideString);
29    procedure setNamedDest(const namedDest: WideString);
30    procedure Print;
31    procedure printWithDialog;
32    procedure setZoom(percent: Single);
33    procedure setZoomScroll(percent: Single; left: Single; top:
34      Single);
35    procedure setView(const viewMode: WideString);
36    procedure setViewScroll(const viewMode: WideString; offset:
37      Single);
38    procedure setViewRect(left: Single; top: Single; width: Single;
39      height: Single);
40    procedure printPages(from: Integer; to_: Integer);
41    procedure printPagesFit(from: Integer; to_: Integer; shrinkToFit:
42      WordBool);
43    procedure printAll;
44    procedure printAllFit(shrinkToFit: WordBool);
45    procedure setShowScrollbars(On_: WordBool);
46    procedure AboutBox;
47    property ControlInterface: _DPdf read GetControlInterface;
48    property DefaultInterface: _DPdf read GetControlInterface;
49  published
50    property TabStop;
51    property Align;
52    property DragCursor;
53    property DragMode;
54    property ParentShowHint;
55    property PopupMenu;
56    property ShowHint;
57    property TabOrder;
58    property Visible;
59    property OnDragDrop;
60    property OnDragOver;
61    property OnEndDrag;
62    property OnEnter;
63    property OnExit;
64    property OnStartDrag;
65    property src: WideString index 1 read GetWideStringProp write
66      SetWideStringProp stored False;
67  end;

finally hereīs an advice: 

You canīt be sure your users will have Acrobat Reader installed so please fisrt check that situation before you take any actions with the TPdf component. And second if your PDF file have links for an AVI file for example, they donīt work from Delphi. 

Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10


Share this page
Download from Google

Copyright © Mendozi Enterprises LLC