Using pdfJSViewer to display Jasper Beans

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:

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!

Hi Skrizvi,

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

Hope this helps

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

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

mboegem:
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.

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.