Jpedal SimpleViewerBean

Hi,

I am trying to get the Jpedal-lgpl SimpleViewerBean to work in my solution. I have placed the bean on my form and I can open a pdf/jpeg with it from using its built-in “File->Open” function. I am trying however to use my method to display a pdf or jpeg stored in a blob.

I don’t have much experience in using some of the 3rd party beans but I thought someone might point me in the right direction.

Here is my code (i named the bean jpedal):

“elements.jpedal.setDocument(documents_to_document_blob.document_blob)”

This is the error I get:

“Can’t find method org.jpedal.examples.simpleviewer.javabean.SimpleViewerBean.setDocument(byte)”

Any pointers would be greatly appreciated!

Thanks!

monetteboy:
This is the error I get:

“Can’t find method org.jpedal.examples.simpleviewer.javabean.SimpleViewerBean.setDocument(byte)”

Any pointers would be greatly appreciated!

Thanks!

This means that you are passing a wrong argument type, probably the jPedal doesn’t want a byte but maybe a file object, have a look at the documentation of the bean.

Using PDF_decoder maybe this snippet will help…

function showPreview()
{
if(file_type==“application/pdf” && forms.YOURFORMNAME_pdf_bean.elements.bean_192)
{
//Note: This displays the screenshot of the PDF ‘Old version’
/application.showFormInDialog( forms.YOURFORMNAME_pdf_bean,700,100,-1,-1,‘Active Version:’+active_version,false,false,false)
forms.YOURFORMNAME_pdf_bean.elements.bean_192.openPdfArray(YOUR_BLOB_NAME)
forms.YOURFORMNAME_pdf_bean.elements.bean_192.decodePage(3)
forms.YOURFORMNAME_pdf_bean.elements.bean_192.setPageParameters(0.4,1)
forms.YOURFORMNAME_pdf_bean.elements.bean_192.repaint();
/

//Note: This displays the screenshot of the PDF ‘New version’ and saves the first page into a blob
//application.showFormInDialog( forms.YOURFORMNAME_pdf_bean,700,100,-1,-1,‘Active Version:’+active_version,false,false,false)
forms.YOURFORMNAME_pdf_bean.elements.bean_192.openPdfArray(YOUR_BLOB_NAME)
forms.YOURFORMNAME_pdf_bean.elements.bean_192.decodePage(1)
forms.YOURFORMNAME_pdf_bean.elements.bean_192.setPageParameters(0.4,1)
forms.YOURFORMNAME_pdf_bean.elements.bean_192.repaint();
//Convert the page into an image and saves it into the blob
var thumbnail=  plugins.images.getImage(forms.YOURFORMNAME_pdf_bean.elements.bean_192.getPageAsImage(1))
var resized = thumbnail.resize(230,230)

forms.YOURFORMNAME_thumbnail = resized
//application.output('this is the image: '+forms.YOURFORMNAME_thumbnail)

}
else
{
//application.showFormInDialog( forms.YOURFORMNAME_image,700,100,-1,-1,‘Active Version:’+active_version,false,false,false)

if(documents_to_document_versions && documents_to_document_versions.image_height > 0)
{
//we DO have a preview available - so show it
forms.YOURFORMNAME_image.elements.image_field.visible = true
forms.YOURFORMNAME_documents.elements.zoomin.visible = true
}
else
{
//hide preview
forms.YOURFORMNAME_image.elements.image_field.visible = false
forms.YOURFORMNAME_documents.elements.zoomin.visible = false
}
}

if(file_type==“image/gif”)
{
forms.YOURFORMNAME_thumbnail = documents_to_document_versions.YOUR_BLOB_NAME
databaseManager.saveData()
}
}

Edward,

Thanks for the code snippet. I tried this with the PDF_decoder bean and it works fine. With the SimpleViewerBean it says it can’t find the OpenPdfArray function. Checking through the methods I don’t see that it has one.

It looks like all I can find is the .setDocument function.

I’ve tried looking for some docs but all I can find is some java code that doesn’t really help me out.

Thanks!

Hi, just curious,

why want you use a bean, to view an image??
you can simply use a MEDIA-field, or a label for that…

EDIT: Ah, I see you also, want to show a pdf.

the pdf decoder is the way to go.
we also have this one working: http://www.qoppa.com/pdfnotes/jpnindex.html which is VERY advanced…

it’s commercial, so not free.

As David Workman pointed to me the othe day, one thing that can display PDF quite nicely is a ServoyBrowser bean ;-)

Try it with the “forceNative” flag to true, and provided that you have installed the pdf plugin in your platform’s browser - IE on Windows, Safari on Mac OS X, Firefox on Linux -, you will get Acrobat inside Servoy.

And it’s free! :)

Excellent information guys…I will try those out!

I still wish I could figure out what I am doing wrong with the other bean…bugs me when I can’t figure something out ;-)

Thanks again!

I am trying to use the jpedal bean to print out pdfs from blob fields, using Paul Bakker’s code from 2006 in servoy 5.

It seams to send the page to the printer on my mac but i get an error.

No %%BoundingBox: comment in header! and then the job dissappears!

Is Jpedal dated now and will the servoybrowser bean help to do blob-> printer directly from servoy?

David

Patrick just saved the day… once again. :D