how to make Thumbnail from pdf, docx, xlsx, ppts?
This information may not be useful in the context of this post, but may be interesting to some.
Some kind of files store the thumbnail also embedded in the same file.
I know only about MS Office files (docx,xlsx,pptx).
While saving these files, there is an option to save "with thumbnails". If the user saves the file with this option a thumbnail image is also saved along with the file. These images are in the
formats of "emf,wmf,jpeg" for "docx,xlsx,pptx" respectively.
In case of MS Office files saved with this option, we can extract the thumbnails and save them, using the FWH built-in function:
- Code: Select all Expand view RUN
OfficeExtractImage( cOfficeFileName, [lReExtract] ) //--> cThumbNailFile saved.
Sample usage:
- Code: Select all Expand view RUN
cThumb := OfficeExtractImage( "mydoc.docx", .t. )
if Empty( cThumb )
? "Thumbnail not saved"
else
? cThumb
XImage( cThumb )
endif
In all other cases, we have to go through the tedious process of displaying the file on the screen, take the screenshot and save it, after resizing if required.
c:\fwh\samples\xblstgrd.prg
c:\fwh\samples\listvie.prg
listvie.prg uses ListView but not xblstgrd.prg. This program uses XBrowse only.
If the purpose of using ListView is to display the application icon along with the filename, I think there are other ways too.
hope is to be able to mimic exactly Windows Explorer capability of showing preview thumbnails of all type of files.
Basic requirement is to "mimic exactly Windows Explorer's functionality".
What Windows Explorer displays in the Preview Pane are NOT thumbnails, but Preview of the file. For this purpose, Windows uses "IPreview Handler" and that is exactly what our program in development is using wherever possible.