Using pdfJSViewer to display Jasper Beans

Forum to discuss the new web client version of Servoy.

Using pdfJSViewer to display Jasper Beans

Postby skrizvi » Thu Jun 20, 2019 11:18 pm

Hello all!

I am trying to convert over a jasperbean to display in the pdfJSViewer and I am a bit unsure about where to start. I was able to generate a pdf and output it to the downloads folder using this code:

Code: Select all
   
plugins.jasperPluginRMI.runReport( fs, reportName, null, plugins.jasperPluginRMI.OUTPUT_FORMAT.PDF, reportArguments )


However what I am trying to do is bring up my generated PDF in the pdfJSviewer like the example on the servoy demo site and allow the user to download the PDF if they are satisfied with the output rather than having them download the report and having to download again.

Thanks!
skrizvi
 
Posts: 17
Joined: Wed Jun 12, 2019 10:13 pm

Re: Using pdfJSViewer to display Jasper Beans

Postby mboegem » Thu Jun 20, 2019 11:44 pm

Hi Skrizvi,

I think what you want can be found here:
viewtopic.php?f=69&t=22487

Hope this helps
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image

Partner of Tower - The most powerful Git client for Mac and Windows
User avatar
mboegem
 
Posts: 1742
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Using pdfJSViewer to display Jasper Beans

Postby rafig » Thu Jun 20, 2019 11:45 pm

Hi
I'm not sure what the 'runReport' returns, but I wanted to display a PDF Invoice that I had generated & stored in a BLOB/Media field in my db using the pdfJSViewer, so using the example I made this
Code: Select all
function loadDocument() {
   if (invoice_image != null) {
      // get invoice image
      var remoteFileName = application.getUUID().toString() + '.pdf';
      var remoteFile = plugins.file.convertToRemoteJSFile('/' + remoteFileName)
      remoteFile.setBytes(invoice_image, true);

      //Convert the remote file to a url, and display it in the PDF viewer
      var remoteUrl = plugins.file.getUrlForRemoteFile('/' + remoteFileName);
      if (remoteUrl) {
         forms.frm_invoice_pdf.elements.pdf_Js_Viewer.documentURL = remoteUrl;
      }
   } else {
      // no image
   }
}

where 'invoice_image' is my media field (or byte array)

Hope that helps.
Rafi
Servoy Certified Developer
Image
rafig
 
Posts: 704
Joined: Mon Dec 22, 2003 12:58 pm
Location: Watford, UK

Re: Using pdfJSViewer to display Jasper Beans

Postby skrizvi » Mon Jun 24, 2019 10:12 pm

mboegem wrote:Hi Skrizvi,

I think what you want can be found here:
viewtopic.php?f=69&t=22487

Hope this helps


Thanks for your help Marc! Just want to leave as a reference on how to suppress the downloads for anyone in the future who wants to use this.

Code: Select all
var byteArray = plugins.jasperPluginRMI.runReport( fs, reportName, { FILENAME: 'report.pdf', DOWNLOAD:false }, plugins.jasperPluginRMI.OUTPUT_FORMAT.PDF, reportArguments );


Pass in { FILENAME: 'report.pdf', DOWNLOAD:false } as your outputOptions argument.
skrizvi
 
Posts: 17
Joined: Wed Jun 12, 2019 10:13 pm


Return to Servoy NGClient

Who is online

Users browsing this forum: No registered users and 4 guests

cron