FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Display thumbnails of pdfs
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Display thumbnails of pdfs
Posted: Wed Oct 19, 2022 08:35 AM
Antonio Linares wrote:
This is a first prototype based on a Karina example:
Code (fw): Select all Collapse
#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?
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM
Re: Display thumbnails of pdfs
Posted: Wed Oct 19, 2022 05:33 PM
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.
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Display thumbnails of pdfs
Posted: Thu Oct 20, 2022 02:06 AM
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 (fw): Select all Collapse
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 (fw): Select all Collapse
waitrun('mutool.exe draw -o "' + cFile + '.png" -r 96 -h 150 "' + cFile + '" 1-1', 0)
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Display thumbnails of pdfs
Posted: Thu Oct 20, 2022 07:01 AM
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.
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Display thumbnails of pdfs
Posted: Thu Oct 20, 2022 07:06 AM
hua wrote:
Antonio Linares wrote:
This is a first prototype based on a Karina example:
Code (fw): Select all Collapse
#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?


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

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

Just give at a try.
Regards



G. N. Rao.

Hyderabad, India
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Display thumbnails of pdfs
Posted: Thu Oct 20, 2022 08:50 AM
nageswaragunupudi wrote:
There another very simple way to view PDF fies
Code (fw): Select all Collapse
HtmlView( FullName( cPdfFile ) )

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


Cool! It feels so light when calling it
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 218
Joined: Mon Feb 07, 2022 09:54 PM
Re: Display thumbnails of pdfs
Posted: Thu Oct 20, 2022 09:53 AM
Please, where do I find the function FullName()?
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Display thumbnails of pdfs
Posted: Thu Oct 20, 2022 10:00 AM
Detlef wrote:Please, where do I find the function FullName()?


This is a (x)Harbour function.
Code (fw): Select all Collapse
FullName( cFileWithRelativePath) --> cFileWithFullPath
Regards



G. N. Rao.

Hyderabad, India
Posts: 218
Joined: Mon Feb 07, 2022 09:54 PM
Re: Display thumbnails of pdfs
Posted: Thu Oct 20, 2022 10:08 AM

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?

Posts: 218
Joined: Mon Feb 07, 2022 09:54 PM
Re: Display thumbnails of pdfs
Posted: Thu Oct 20, 2022 10:19 AM
I found out that it should be TrueName() :-)
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Display thumbnails of pdfs
Posted: Thu Oct 20, 2022 11:32 AM

Dear Detlef,

many thanks for sharing it! :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Display thumbnails of pdfs
Posted: Thu Oct 20, 2022 02:54 PM
Detlef wrote:I found out that it should be TrueName() :-)

Sorry for the typo
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Display thumbnails of pdfs
Posted: Wed Nov 02, 2022 08:21 AM
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:


Our application mimics windows explorer this way:


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



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Display thumbnails of pdfs
Posted: Wed Nov 02, 2022 08:26 AM
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.
Regards



G. N. Rao.

Hyderabad, India
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Display thumbnails of pdfs
Posted: Wed Nov 02, 2022 10:13 AM
Something similar to this Rao. Thank you very much.
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour