Solved

PDF Viewer

Posted on 2006-07-06
19
3,625 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
19 Comments
 
LVL 28

Expert Comment

by:ciuly
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:ciuly
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
 

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:ciuly
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:ciuly
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

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:ciuly
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:ciuly
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:ciuly
ID: 17056873
hm... I'll do some testing then and will let you know.
0
 
LVL 28

Expert Comment

by:ciuly
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:
ciuly 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now