Solved

PDF Viewer

Posted on 2006-07-06
19
3,635 Views
Last Modified: 2008-01-09
Hi,

Anyone know a good "FREE" PDF viewer component for Delphi 7.0 ?

I just want to be able to view a PDF file inside a Delphi Form.

Thanks.
0
Comment
Question by:kapot
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
19 Comments
 
LVL 28

Expert Comment

by:2266180
ID: 17049583
Hi kapot,

you could use the acrobat activex control (you install acrobat reader to have the activex contr installed on your system, then you import it in delphi)

Cheers!
0
 
LVL 28

Expert Comment

by:2266180
ID: 17049596
regarding mz post above, this might help http://community.borland.com/article/0,1410,22101,00.html
0
 
LVL 14

Expert Comment

by:Hamidreza Vakilian
ID: 17049922
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:kapot
ID: 17050447
Yes, I found that I can use the OCX supplied by the Acrobat Reader.

However, there are 2 versions of OCX :

PDF.OCX for Acrobat 6 and old version
AcroPDF.DLL for Acrobat 7

Now I am confuse, how to support both version ?

If I imported the AcroPDF.DLL and the user does not have Acrobat 7 installed, it wont work.
If I imported the PDF.OCX and the user uses Acrobat 7, it wont work either.

How to handle this situation ?
0
 
LVL 28

Expert Comment

by:2266180
ID: 17050581
are you sure it's not the same com interface? I only have version 7 but it would seem antural that using version six, should work with version 7.
0
 
LVL 11

Expert Comment

by:calinutz
ID: 17053593
Do not forget that the computer you will be running your application must have the Acrobat reader installed in order to let your application view the pdf...
0
 

Author Comment

by:kapot
ID: 17054107
I am sorry that I dont understand this.

In my system, I have Acrobat Reader 6 installed. I dont like Acrobat Reader 7 because it is slow.

So, I will import that PDF.OCX and apply it into my application.

How come people with Acrobat 7 will be able to use my application ? Because the ActiveX is different.
0
 
LVL 28

Expert Comment

by:2266180
ID: 17054158
the dll is different. if the activex (com) object will implement the same interface (the basics of COM), then there is not problem. the iportant thig is that it be the same interface. and I strongly doubt that acrobat will change the interface from one version to the other making things not compatible. it is just not the way things are done in software bussiness: golden rule says you need to keep compatibility otherwise the clients (that give you the money for the software) will be unhappy and stop using your product and will use another one that doesnt have this version limitation ;)
it's all marketing in the end :) version 7 must be compatible with most previous versions. you can make a small test application and have some firend of yours that have version 7 installed do a small test if you will feel more confortable with that.
0
 

Author Comment

by:kapot
ID: 17054349
I did make a small test, but I found the activex (PDF.OCX) is NOT reliable.

It can open a pdf, but not for the second time. Whatever I tried, it will give Access Violation error :(

I tried to run the EXE outside IDE, still error.

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, OleCtrls, PdfLib_TLB, ExtCtrls, StdCtrls, Mask, ActiveX;

type
  TForm1 = class(TForm)
    Pdf1: TPdf;
    Panel1: TPanel;
    Panel2: TPanel;
    Button1: TButton;
    OpenDialog1: TOpenDialog;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  OpenDialog1.Filter := 'PDF Files (*.pdf)|*.pdf';
  if OpenDialog1.Execute then
  begin
    Pdf1.src := OpenDialog1.FileName;
  end;
end;

end.
0
 

Author Comment

by:kapot
ID: 17054385
But I think I fixed it like this :

procedure TForm1.Button1Click(Sender: TObject);
begin
  OpenDialog1.Filter := 'PDF Files (*.pdf)|*.pdf';
  if OpenDialog1.Execute then
  begin
    if Pdf1 <> nil then Pdf1.Free;
    Pdf1 := TPdf.Create(Self);
    Pdf1.Parent := Panel2;
    Pdf1.Align := alClient;
    Pdf1.src := OpenDialog1.FileName;
  end;
end;

The activex is recreated everytime.

Any other tips ??? Cleaner code :)
0
 
LVL 28

Expert Comment

by:2266180
ID: 17054391
hm.. what if you change that line into pdf1.loadfromfile(OpenDialog1.FileName); ? will it still give error?
0
 
LVL 28

Expert Comment

by:2266180
ID: 17054422
we posted almost in the same time. I was referring to your first post with code
0
 

Author Comment

by:kapot
ID: 17056724
I tested on a machine with Acrobat 7 installed, it does not work :(

When it start, error came up :

PDFViewer.exe has generated errors and will be closed by Windows ...

Bad news :(
0
 
LVL 28

Expert Comment

by:2266180
ID: 17056873
hm... I'll do some testing then and will let you know.
0
 
LVL 28

Expert Comment

by:2266180
ID: 17079192
update:
well, I didn't find an acrobat 6 machine, but I found an acrobat 5 machine. made a small test app and tested it on my acrobat 7 machine and it indeed crashed.

next step, I will use oleautomation to create the acrobat application com object and will let you know of the results in about 24 hours.
0
 

Author Comment

by:kapot
ID: 17120650
ciuly,

I read in the planetpdf.com forum (PDF developer), it said that pdf.ocx is not supported and it was a crappy component.

They suggested to use the Acrobat SDK which is free for this case.

I havent tried it and I dont think I am capable enough with it because if I am not mistaken, the SDK does not support Delphi. I am not sure.
0
 
LVL 28

Accepted Solution

by:
2266180 earned 105 total points
ID: 17128390
Hi,

sorry for the blackout. I had to leave country and just couldn't find an open window to test my findings. (not oleautomation)
I found this link: http://www.delphipages.com/threads/thread.cfm?ID=167476&G=167472 so I just created the component at runtime and it did not cive an error (so, program exe compiled on machine with acrobat 5 and run on machine with acrobat 7)

so, remove the component from the form in the designer, put it manually in the private section of the form and in the formcreate event, create it and assign the documetn if needed plus setting teh necessary properties, like visibility, etc) and in teh formdestroy free it.

it should remove any compatibility issues without making any other radical changes to the code.

cheers
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question