Pdf preview in media fields

Since Dev Team is doing such a great job with image files management, I’d like to add a request to the wish list:

it would be great to to able to see a thumbnail of the first page of a pdf document, when this one is stored in a blob field.

As an alternative, also a function that creates a thumbnail in jpeg or png format would be fine.

What do you think?

I also REALLY need this feature!. THANK YOU IN ADVANCE DEV DREAM TEAM!!!

…and what about an easy way to display the blob-pdf directly on a form?

here is a pdf bean that you can drop in the beans folder.

loading of a pdf:

globals.page = 1;
globals.zoomfactor = 0.2;
var file = plugins.file.showFileOpenDialog(1);
if(file)
{
	elements.bean_185.openPdfFile(file);
	elements.bean_185.decodePage(globals.page);
	elements.bean_185.setPageParameters(globals.zoomfactor, globals.page);
	elements.bean_185.repaint();
}

next page:

globals.page++;
elements.bean_185.decodePage(globals.page);
elements.bean_185.setPageParameters(globals.zoomfactor, globals.page);
elements.bean_185.repaint();

jcompagner:
here is a pdf bean that you can drop in the beans folder.

Guys, you’re really great! :-D

Thanks: it’s a precious tool and I can’t wait to use it :-)

THANKS JOHAN. that was a really quick response!! IT WORKS!!! it is exactly what I was looking for. WONDERFUL !!!

TO all members of this forum
TAKE NOTE: Our was not an easy request … but SERVOY dev DREAM team found and tested the right solution for us in less than 3 days!!!
I owe you a big box of Torino’s GIANDUJOTTI.

GRAZIE

For loading a pdf from a blob field:

elements.bean_185.openPdfArray(blob_pdf)

where blob_pdf is the media/blob field.

WONDERFUL

thanks again

VERY COOL STUFF! :D

Sorry, I can’t get it working :oops:
Installed the bean, placed the bean on a form, created a mediafield and pasted a PDF in it, and the two globals.
Finally I made a method and pasted the code in it.
What do I put into the methods (pdf from a blobfield as well as from outside the db)?

TIA

Ron

The methods work with the element name of the beanelement you dropped on your form. Did you name the element and synced the element name used in the methods to it?

Paul

Hi Paul,

Yep, I did rename the beannames in my method, that was not the problem.
I did set the zoomfactor 2 and enlarged the bean size, and now
the pdf from my HD shows up fine.
However I am still struggling with de pdf stored in the mediafield.
This is the code I use:

globals.page = 1;
globals.zoomfactor = 2;
var file = elements.bean_185.openPdfArray(pdf_in_mediafield);
if(file)
{
elements.bean_185.openPdfFile(file);
elements.bean_185.decodePage(globals.page);
elements.bean_185.setPageParameters(globals.zoomfactor, globals.page);
elements.bean_185.repaint();
}

Any suggestions?

you are using BOTH pdf from file and pdf from array!!
you shouldn’t ofcourse use both!

var file = elements.bean_185.openPdfArray(pdf_in_mediafield);

elements.bean_185.openPdfFile(file);

if you debugged this then you should see that file after the first call is undefined.. Is nothing. Because openPdfArray doesn’t return a file.. It shows the pdf that is defined in the array. Just as openPdfFile shows the pdf defined in the file object…

elements.bean_185.openPdfArray(pdf_in_mediafield); 
elements.bean_185.decodePage(globals.page); 
elements.bean_185.setPageParameters(globals.zoomfactor, globals.page); 
elements.bean_185.repaint();

You’re right.
Thanks Johan.

Is thier a way to use this bean to add and position text. ie) For instance to programatically fill out a form?

John McCann

Is thier a way to use this bean to add and position text. ie) For instance to programatically fill out a form?

John McCann

No not possible but maybe we could build a merge function for PDF forms based on the lib used by the pdf printer plugin

Where is the download link for this bean?

http://downloads.servoy.com/beta/jpedal.jar

thanks johan :D

jcompagner:
here is a pdf bean that you can drop in the beans folder.

Where is this bean?

Excuse me for asking but it’s not the first time I’ve seen reference to a file/bean as if it was provided as an attachment and simply is nowhere to be seen! I feel pretty stupid can somebody explain me what’s happening?

Txs,
mjekl

just look two posts upward…