What is the best way to display a PDF file in Delphi 2009 [closed]

廉价感情. 提交于 2019-11-30 09:38:38

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.

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.

Naas_it

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!