Page 2 of 3

Re: Display thumbnails of pdfs

PostPosted: Wed Oct 19, 2022 8:35 am
by hua
Antonio Linares wrote:This is a first prototype based on a Karina example:
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oWndPdf, oPdf

   DEFINE WINDOW oWndPdf TITLE "Generating thumbnail"

   oPdf := TActiveX():New( oWndPdf, "AcroPDF.PDF.1" )
   oWndPdf:oClient := oPdf
   oPdf:Do( "LoadFile", "fwintro.pdf" )

   ACTIVATE WINDOW oWndPdf MAXIMIZED ;
            ON INIT( oWndPdf:SetSize( 200, 300 ), oWndPdf:Center(), PDFActivex(),;
                     SysWait( 1 ), oWndPdf:oClient:SaveToBmp( "thumbnail.bmp" ), oWndPdf:End() ) ;
            VALID ( oPdf:End(), .T. )
...
 


I got a scrollbar when I tried this. I'm also guessing this approach requires Adobe Acrobat pre-installed on user's pc?
Image

Re: Display thumbnails of pdfs

PostPosted: Wed Oct 19, 2022 5:33 pm
by AntoninoP
I remember a lot of time ago I did something similar: https://forums.fivetechsupport.com/viewtopic.php?f=3&t=30904 that takes the control from registry.

Re: Display thumbnails of pdfs

PostPosted: Thu Oct 20, 2022 2:06 am
by hua
Just to record here that I noticed mutool uses AGPL license which can easily run afoul of.
So I've replaced it with convert.exe from ImageMagick for now. Still need to test what will happen if use convert.exe on machine without Ghostscript installed.

This is the command I used to create thumbnail from the 1st page of a pdf. 0 points to the page number
Code: Select all  Expand view
convert -alpha off -density 150 -resize 96 a.pdf[0] a.jpg
 


hua wrote:Thanks for the tip regarding mutool Jimmy.
Since it's just a one liner, I managed to make it run using this code without having to create a batch file
Code: Select all  Expand view
waitrun('mutool.exe draw -o "' + cFile + '.png" -r 96 -h 150 "' + cFile + '" 1-1', 0)
 

Re: Display thumbnails of pdfs

PostPosted: Thu Oct 20, 2022 7:01 am
by nageswaragunupudi
AntoninoP wrote:I remember a lot of time ago I did something similar: https://forums.fivetechsupport.com/viewtopic.php?f=3&t=30904 that takes the control from registry.


Yes, you did.
Thanks for your contribution.

The present preview application I am developing is based on this and works wonderfully. Same way like the Windows Explorer.
If you can spare your time at your convenience, I would like to take your help for some file extensions that are not working for me.

Re: Display thumbnails of pdfs

PostPosted: Thu Oct 20, 2022 7:06 am
by nageswaragunupudi
hua wrote:
Antonio Linares wrote:This is a first prototype based on a Karina example:
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oWndPdf, oPdf

   DEFINE WINDOW oWndPdf TITLE "Generating thumbnail"

   oPdf := TActiveX():New( oWndPdf, "AcroPDF.PDF.1" )
   oWndPdf:oClient := oPdf
   oPdf:Do( "LoadFile", "fwintro.pdf" )

   ACTIVATE WINDOW oWndPdf MAXIMIZED ;
            ON INIT( oWndPdf:SetSize( 200, 300 ), oWndPdf:Center(), PDFActivex(),;
                     SysWait( 1 ), oWndPdf:oClient:SaveToBmp( "thumbnail.bmp" ), oWndPdf:End() ) ;
            VALID ( oPdf:End(), .T. )
...
 


I got a scrollbar when I tried this. I'm also guessing this approach requires Adobe Acrobat pre-installed on user's pc?
Image


There another very simple way to view PDF fies
Code: Select all  Expand view
HtmlView( FullName( cPdfFile ) )

It works the same way. Don't bother about installing anything.

Just give at a try.

Re: Display thumbnails of pdfs

PostPosted: Thu Oct 20, 2022 8:50 am
by hua
nageswaragunupudi wrote:There another very simple way to view PDF fies
Code: Select all  Expand view
HtmlView( FullName( cPdfFile ) )

It works the same way. Don't bother about installing anything.


Cool! It feels so light when calling it

Re: Display thumbnails of pdfs

PostPosted: Thu Oct 20, 2022 9:53 am
by Detlef
Please, where do I find the function FullName()?

Re: Display thumbnails of pdfs

PostPosted: Thu Oct 20, 2022 10:00 am
by nageswaragunupudi
Detlef wrote:Please, where do I find the function FullName()?


This is a (x)Harbour function.
Code: Select all  Expand view
FullName( cFileWithRelativePath) --> cFileWithFullPath

Re: Display thumbnails of pdfs

PostPosted: Thu Oct 20, 2022 10:08 am
by Detlef
Mr. Rao,

I can't find this function in any of my docs and unfortunately I get an Unresolved external '_HB_FUN_FULLNAME'.
What am I missing?

Re: Display thumbnails of pdfs

PostPosted: Thu Oct 20, 2022 10:19 am
by Detlef
I found out that it should be TrueName() :D

Re: Display thumbnails of pdfs

PostPosted: Thu Oct 20, 2022 11:32 am
by Antonio Linares
Dear Detlef,

many thanks for sharing it! :-)

Re: Display thumbnails of pdfs

PostPosted: Thu Oct 20, 2022 2:54 pm
by nageswaragunupudi
Detlef wrote:I found out that it should be TrueName() :D

Sorry for the typo

Re: Display thumbnails of pdfs

PostPosted: Wed Nov 02, 2022 8:21 am
by nageswaragunupudi
Mr. hua
I know you asked for pdf thumbnails and this is not exactly what you asked.
But this application mimics windows explorer showing preview of files, same way as explorer.
We will get back you on thumbnails a bit later.

This is how Windows Explorer displays previews:
Image

Our application mimics windows explorer this way:
Image

Click "Open" button or Double-Click on file name opens the file with its associated application.

Re: Display thumbnails of pdfs

PostPosted: Wed Nov 02, 2022 8:26 am
by nageswaragunupudi
hua wrote:Is it possible to display thumbnails showing a preview of pdfs like what we can see at Windows Explorer?
That's the starting point my hope is to be able to mimic exactly Windows Explorer capability of showing preview thumbnails of all type of files.

TIA


Can you please provide a screenshot of windows explorer displaying "thumbnails of pdfs", so that we get to know what exactly you are looking for.

Re: Display thumbnails of pdfs

PostPosted: Wed Nov 02, 2022 10:13 am
by hua
Something similar to this Rao. Thank you very much.
Image