Question

What component should I use to display a PDF file in a Delphi 2009 application?

EDIT:

I have been using PDF Viewer by Synactis - a very nice free PDF Viewer But it has no Delphi 2009 support.

So I need to designing it out of the product

Was it helpful?

Solution

We embedded the Acrobat Reader in our Delphi application. Take a look at this article "How to embed Adobe Acrobat into your application". Once you have added the Acrobat Reader ActiveX component to your Form you can use following code:

procedure TForm1.Button1Click(Sender: TObject); 
begin
  // This example assumes that you have a TOpenDialog
  // and TPdf dropped onto your form
  OpenDialog1.Filter := 'PDF Files (*.pdf)|*.pdf';
  if OpenDialog1.Execute then
    Pdf1.src := OpenDialog1.FileName;
end;

There is native Delphi components out there but embedding the Acrobat Reader component served our needs.

OTHER TIPS

I have a feeling that more and more users prefere alternatives to acrobat reader, so forcing them to install acrobat to use your progam is a bad idea.

The ProPlus version of Gnistice PDFtoolkit let you display pdf files. And so does QuickPDFLibrary. I'm sure there are more of them.

Launching the file in the users prefered pdf viewer could be a second option for better controlling printing etc.

If all you want to achieve is displaying a pdf, why not just start the application the user installed for viewing pdf files? This way they won't get annoyed by your program ignoring their choice and will also be already familiar with the program.

Other options include using Adobe's acrobat reader plugin as Kris De Decker suggests or the plugins I am sure alternative viewers also supply. This will potentially give you some more control, but you will for sure also find that the control is not as thorough as you would like.

It is possible to use a Twebbrowser or a Bsalsa web document, URL encode the filepath and pass it as a web document - it will load the default PDF application within the browser area.

WPCubed (http://wptools.de/) offers WPViewPDF tools with a royalty free distribution license, and Delphi support - 4,5,6,7, 2005, 2006, 2007, BCB 5,6,2006, 2007

I have not used the wptools PDF viewer, but I can say their other PDF tools are top notch.

Embeded original Acrobat Reader ActiveX in Delphi is the best way and free. If you want to create PDF, that's cost a lot.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top