Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3640
  • Last Modified:

PDF Viewer

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
kapot
Asked:
kapot
1 Solution
 
2266180Commented:
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
 
2266180Commented:
regarding mz post above, this might help http://community.borland.com/article/0,1410,22101,00.html
0
 
Hamidreza VakilianSenior iOS DeveloperCommented:
0
Industry Leaders: 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!

 
kapotAuthor Commented:
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
 
2266180Commented:
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
 
calinutzCommented:
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
 
kapotAuthor Commented:
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
 
2266180Commented:
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
 
kapotAuthor Commented:
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
 
kapotAuthor Commented:
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
 
2266180Commented:
hm.. what if you change that line into pdf1.loadfromfile(OpenDialog1.FileName); ? will it still give error?
0
 
2266180Commented:
we posted almost in the same time. I was referring to your first post with code
0
 
kapotAuthor Commented:
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
 
2266180Commented:
hm... I'll do some testing then and will let you know.
0
 
2266180Commented:
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
 
kapotAuthor Commented:
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
 
2266180Commented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now