Welcome! Log In Create A New Profile

Advanced

[WD22] Thumbnails for pdf files

Posted by Michael Drechsel 
[WD22] Thumbnails for pdf files
October 18, 2018 03:15PM
Hi,

is there any chance to get thumbnails from pdf files out of the box and if yes how ?
If no: Has anybody a solution ?

regards Michael

regards Michael
Re: [WD22] Thumbnails for pdf files
October 18, 2018 03:40PM
Hi Michael

thumbnails in what context?

Thumbnails of which page of the pdf? The first one? All?

One solution to create thumbanisl is to display the pdf in a small image field (the size of the thumbnail you want) and do a saveimagejpg of that image field; but without more information, I'm not sure I'm really answering your question.

Best regards

Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Free Video Courses, free WXShowroom.com, open source WXReplication, open
source WXEDM.

More information on [www.fabriceharari.com]
Re: [WD22] Thumbnails for pdf files
October 18, 2018 04:34PM
Hi Fabrice,

the user want the same functionality like the pdf preview in the windows file explorer.

regards Michael
Re: [WD22] Thumbnails for pdf files
October 18, 2018 04:43PM
Hi Michael,

then you can just display the pdf itself in an image field (myImageFIeld=MyPDfFile).That's what the windows file explorer is doing anyway, if the slow display of big pdf fields is any indication.

Best regards

Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Free Video Courses, free WXShowroom.com, open source WXReplication, open
source WXEDM.

More information on [www.fabriceharari.com]
Re: [WD22] Thumbnails for pdf files
October 18, 2018 05:48PM
Ok,

he wants a complete preview of all pages without downloading it.
My idea is now to extract the pages with a low resolution as jpg and put it in a database.

Can I create these pdf pictures with the image field in a service ?

regards Michael
Re: [WD22] Thumbnails for pdf files
October 18, 2018 06:28PM
Hi Michael

I have never tried in a service, and as services limitation is all about UI, and saving the content of an image field is too; there MAY be a problem there. It would definitely work with a regular exe running all the time, but you'll have to try doing it in a service, as I'm not sure about it.

OR... You could create all the thumbnails at the time when the pdf is introduced into the system, in the same code of the upload or file selection.

best regards

Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Free Video Courses, free WXShowroom.com, open source WXReplication, open
source WXEDM.

More information on [www.fabriceharari.com]
Re: [WD22] Thumbnails for pdf files
October 18, 2018 07:15PM
Afaik GUI elements are no problem in a service configuration. As long as it isn't blocking.

I once had a maintenance window which was executed as a regular exe. It opened a window with some static-controls and a progressbar and a button. When the user pressed the start-button the code to import a bunch of files was executed. This exe had to run with a user logged in.

Later I added an extra project-configuration to create a service. From the "running the service" section (which is running in a loop when using services) I opened the very same window. And at the end of the initialization-section the button-code was automatically started. ie.
IF InServiceMode() THEN
StartImport()
Close(MyWindow)
END
Worked like a charm, including updating the progressbar and so on.

This was in my early WD days. Now I would put all that code in classes and procedures and run it without all the GUI-stuff winking smiley

Arie
Re: [WD22] Thumbnails for pdf files
October 18, 2018 07:23PM
But maybe you could also use image variables instead of controls, to avoid GUI stuff?

Arie
Re: [WD22] Thumbnails for pdf files
October 18, 2018 07:28PM
Quote
My idea is now to extract the pages with a low resolution as jpg and put it in a database

That could work. I've done this before using an imagecontrol to load the Original PDF. Then use the ..NumberPage and .. PageNumber properties to get the individual pages and copy them to a second control.

Something like this where IMG_PDF and IMG_JPG are image controls. But image variables may also work, I'm not sure.

sPDF is string = "the_full_pdf_file"
sJPG is string = "some_jpg"
nPages is int = PDFNumberOfPages(sPDF)
nPage is int
nQuality is int = 20
LOOP(nPages)
IMG_PDF = sImage
nPage++
IMG_PDF..PageNumber = nPage
IMG_JPG = IMG_PDF
dSaveImageJPEG(IMG_JPG, sJPG+nPage, nQuality)
END

Arie
Re: [WD22] Thumbnails for pdf files
October 18, 2018 08:54PM
Hi Fabrice and Arie,

thx for the hints. I try it at the same way like Aries code snippet.

regards Michael
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: