BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Opening PDF files in Delphi 6

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation
View previous topic :: View next topic  
Author Message
Peter Tickler
Guest





PostPosted: Tue Jan 11, 2005 3:59 pm    Post subject: Opening PDF files in Delphi 6 Reply with quote




I am trying to open PDF files from within my delphi 6 application. I have done similar things for other types of file (Word, Excel, etc), but the same approach won't work for PDF files.
So I have put a Tpdf component on my form, then two lines of code thus:

type
TfmAcrobat = class(TForm)
Pdf1: TPdf;
private
{ Private declarations }
NewPDFapp: Tpdf;
public
procedure Open (pdfFile: OleVariant);
{ Public declarations }
end;

var
fmAcrobat: TfmAcrobat;

implementation

{$R *.dfm}

{ TfmAcrobat }

procedure TfmAcrobat.Open(pdfFile: OleVariant);
begin
NewPDFapp := TPdf.Create(Self);
NewPDFapp.src := pdfFile;
end;

When the open code runs, Acrobat Readers appears to start loading, then it disappears and the file is not opened (the application just hangs). I have a feeling this is a known problem. Does anyone out there know the solution?!

Thanks.
Back to top
eshipman
Guest





PostPosted: Tue Jan 11, 2005 4:49 pm    Post subject: Re: Opening PDF files in Delphi 6 Reply with quote



In article <41e3f7e6$1 (AT) newsgroups (DOT) borland.com>, [email]ptickler (AT) potato (DOT) org.uk[/email]
says...
Quote:

I am trying to open PDF files from within my delphi 6
application. I have done similar things for other types
of file (Word, Excel, etc), but the same approach won't
work for PDF files.

So I have put a Tpdf component on my form, then two lines
of code thus:

type
TfmAcrobat = class(TForm)
Pdf1: TPdf;
private
{ Private declarations }
NewPDFapp: Tpdf;
public
procedure Open (pdfFile: OleVariant);
{ Public declarations }
end;

var
SNIP wrong code
When the open code runs, Acrobat Readers appears to start
loading, then it disappears and the file is not opened (the
application just hangs). I have a feeling this is a known
problem. Does anyone out there know the solution?!

You are doing it WRONG.

Since you imported the Type Lib, just drop the TPDF on your form and set
it's src property to the filename you want to open.

Back to top
Peter Tickler
Guest





PostPosted: Thu Jan 13, 2005 8:58 am    Post subject: Re: Opening PDF files in Delphi 6 Reply with quote




eshipman <mr_delphi_developer@yahoo!!!.com> wrote:
Quote:
You are doing it WRONG.

Since you imported the Type Lib, just drop the TPDF on your form and set
it's src property to the filename you want to open.

I have tried that and it still doesn't work.

I have also tried opening the files with ShellExecute, thus:

ShellExecute(0, 'Open', PChar(pdfFile), PChar(''), PChar(''), SW_SHOWNORMAL);

This doesn't work either. That is to say, it doesn't show the file - however Acrobat appears to open, and then disappears, and the file I am trying to open never appears. I also test for success, and it says it has been successful.

I can open a pdf file via Windows Explorer by double clicking on it.

This leads me to think there is something odd in the way Delphi and Acrobat reader interact, and I wondered if this was a known problem, and if so what was the solution.

Peter

Back to top
George Birbilis
Guest





PostPosted: Thu Jan 13, 2005 12:08 pm    Post subject: Re: Opening PDF files in Delphi 6 Reply with quote

does the Acrobat Reader work in other ActiveX containers like Visual
Studio.net?

it might be an OLE Control, not supporting the ActiveX stuff so try dropping
it inside a TOleContainer component

Quote:
You are doing it WRONG.

Since you imported the Type Lib, just drop the TPDF on your form and set
it's src property to the filename you want to open.

I have tried that and it still doesn't work.

I have also tried opening the files with ShellExecute, thus:

ShellExecute(0, 'Open', PChar(pdfFile), PChar(''), PChar(''),
SW_SHOWNORMAL);

This doesn't work either. That is to say, it doesn't show the file -
however Acrobat appears to open, and then disappears, and the file I am
trying to open never appears. I also test for success, and it says it has
been successful.

I can open a pdf file via Windows Explorer by double clicking on it.

This leads me to think there is something odd in the way Delphi and
Acrobat reader interact, and I wondered if this was a known problem, and
if so what was the solution.

Peter



Back to top
eshipman
Guest





PostPosted: Thu Jan 13, 2005 5:48 pm    Post subject: Re: Opening PDF files in Delphi 6 Reply with quote

In article <41e6384c$1 (AT) newsgroups (DOT) borland.com>, [email]ptickler (AT) potato (DOT) org.uk[/email]
says...
Quote:

eshipman <mr_delphi_developer@yahoo!!!.com> wrote:
You are doing it WRONG.

Since you imported the Type Lib, just drop the TPDF on your form and set
it's src property to the filename you want to open.

I have tried that and it still doesn't work.

I have also tried opening the files with ShellExecute, thus:


No, try reinstalling the reader, first.

Back to top
Peter Tickler
Guest





PostPosted: Fri Jan 14, 2005 9:12 am    Post subject: Re: Opening PDF files in Delphi 6 Reply with quote


eshipman <mr_delphi_developer@yahoo!!!.com> wrote:
Quote:
No, try reinstalling the reader, first.

Just installed a new version (6.0 rather than 5.0) of Acrobat Reader and it now works fine!!!

Thanks a lot guys.

Peter

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.