Universal "document / image viewer" for Delphi?

I want to view (only) image files and some common documents (PDF, RTF, TEXT, etc.) in my Delphi program, I found two ways to do this,

  • via AtViewer , but the file size is too large.
  • Through the built-in Internet Explorer, installed directly on the end user’s computer.

I am wondering if there are alternatives? Thanks.

+4
source share
4 answers

There are two ways:

  • Use any software provided by Windows
  • Stick to Delphi's built-in components.

I personally like to keep my source "all delphi". When it comes to displaying images, Delphi is blessed with many third-party libraries that provide you with support for almost any image format you can imagine.

Images

ImageEN is a good (commercial) package and you might also like the free Vapyre image library (the name is a little ... well, but it's a great product). To quickly add support for the most common formats, GraphicsEX is a traditional Delphi extension that is used by many developers. You also have FreeImage, which is a collection of DLL files, but with Delphi shell classes to make them easy to use. look in the graphic section on the pages of Torry Delphi (google it) and you will find reliable support.

Pdf

For viewing and reading PDF, I would look at the Gnostice product line. They provide Delphi's own components for creating and viewing PDF files (http://www.gnostice.com/). As an alternative (for PDF), I would probably go for the ActiveX components that come with the Adobe PDF reader. But then you have to check that these objects are registered and available for your application at startup.

So, for your "universal viewer" I would

  • Create a basic form for viewing (to provide buttons, status bar, etc.).
  • Add a virtual method to open a file
  • Cancel 3 forms from this so that each transaction has a different type of media. This way you get TfrmPDF, TfrmImage and TfrmHTML. In each case, override the open () method. Thus, your main application does not have to worry about the details of each format.

HTML

You are lucky to view HTML, as Delphi has its own web rendering of its own. It was written by Steve Baldwin and is called THTMLViewer. It was released as open source and you will find it on google projects.

+4
source

Windows (since XP, if I remember correctly) uses the IExtractImage interface to create thumbnails for any file as thumbnails if it has an object specified for its file type.

These objects are accessible by code, and you can use them to create thumbnails for any file that also receives thumbnails in Windows Explorer. (I even think that thumbnails will come from the thumbnail cache ( Thumbs.db ) if it is available in the size of the image you request.)

There is still here: http://yoy.be/item.asp?i1490 or here: http://msdn.microsoft.com/en-us/library/bb775073(v=vs.85).aspx

+4
source

I would suggest that you write your own TForm viewer that looks at the file being viewed and does one of three (or four or five) things with it:

  • If it is PDF or HTML, download it with the IE built-in web browser (TEmbeddedWB from www.bsalsa.com is better than the included VCL TwebBrowser IE wrapper).

  • If it is an image, upload it to an image viewer control that supports resizing / scaling / scrolling.

  • If it is a text file or an RTF file, upload it to RichEdit.

  • If it is an OLE type, you can view it in the OLE container view.

+2
source

The built-in viewer will display any documents, however if it requires an external viewer, it will be displayed outside of IE - TIFFs for each of them are displayed (by default) in the image viewer.

0
source

Source: https://habr.com/ru/post/1334027/


All Articles