Display thumbnails of pdfs

Re: Display thumbnails of pdfs

Postby hua » Wed Oct 19, 2022 8:35 am

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
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: Display thumbnails of pdfs

Postby AntoninoP » Wed Oct 19, 2022 5: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.
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Display thumbnails of pdfs

Postby hua » Thu Oct 20, 2022 2: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: 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)
 
Last edited by hua on Wed Dec 28, 2022 11:06 am, edited 1 time in total.
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: Display thumbnails of pdfs

Postby nageswaragunupudi » Thu Oct 20, 2022 7: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
User avatar
nageswaragunupudi
 
Posts: 10641
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Display thumbnails of pdfs

Postby nageswaragunupudi » Thu Oct 20, 2022 7:06 am

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.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10641
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Display thumbnails of pdfs

Postby hua » Thu Oct 20, 2022 8:50 am

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
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: Display thumbnails of pdfs

Postby Detlef » Thu Oct 20, 2022 9:53 am

Please, where do I find the function FullName()?
User avatar
Detlef
 
Posts: 209
Joined: Mon Feb 07, 2022 9:54 pm

Re: Display thumbnails of pdfs

Postby nageswaragunupudi » Thu Oct 20, 2022 10:00 am

Detlef wrote:Please, where do I find the function FullName()?


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

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10641
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Display thumbnails of pdfs

Postby Detlef » 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?
User avatar
Detlef
 
Posts: 209
Joined: Mon Feb 07, 2022 9:54 pm

Re: Display thumbnails of pdfs

Postby Detlef » Thu Oct 20, 2022 10:19 am

I found out that it should be TrueName() :D
User avatar
Detlef
 
Posts: 209
Joined: Mon Feb 07, 2022 9:54 pm

Re: Display thumbnails of pdfs

Postby Antonio Linares » Thu Oct 20, 2022 11:32 am

Dear Detlef,

many thanks for sharing it! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Display thumbnails of pdfs

Postby nageswaragunupudi » Thu Oct 20, 2022 2:54 pm

Detlef wrote:I found out that it should be TrueName() :D

Sorry for the typo
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10641
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Display thumbnails of pdfs

Postby nageswaragunupudi » Wed Nov 02, 2022 8: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:
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.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10641
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Display thumbnails of pdfs

Postby nageswaragunupudi » Wed Nov 02, 2022 8: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
User avatar
nageswaragunupudi
 
Posts: 10641
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Display thumbnails of pdfs

Postby hua » Wed Nov 02, 2022 10:13 am

Something similar to this Rao. Thank you very much.
Image
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 39 guests