Project

General

Profile

Defect #388

unable to return generated report (pdf) in a function

Added by Jos de Bruijn over 12 years ago. Updated over 12 years ago.

Status:
Closed
Priority:
High
Start date:
11/03/2011
Due date:
% Done:

0%

Estimated time:
Browser (if web client):

Description

I've got a function that has to return a generated report in PDF format.
I'm using the code sample as guide line (last 2 comment lines below are from the sample code) but my result is always NULL.

function e_reportEmployeeTasks(emp_id, type) {
      var server = _to_gb_owner.database_name;
      if (!server)
            server = "welcome";
      var _params = new java.util.HashMap();
      _params.put("P_EMP_ID", emp_id)
      var _res = plugins.jasperPluginRMI.runReport(server,'TakenMedewerker.jrxml',null,OUTPUT_FORMAT.PDF,_params) 
      return _res

      //The return value is a byte array with the content of the file generated that can be further used.
      //var res = plugins.jasperPluginRMI.runReport(currentcontroller.getServerName(),'samplereport.jrxml', null, OUTPUT_FORMAT.PDF, null);
      //plugins.file.writeFile('e:\\sample.pdf', res);
}

When I change the output format to VIEW then the function does show a report (but also returns a null)
I'm using the 3.2.0 version of the plugin

History

#1

Updated by Harjo Kompagnie over 12 years ago

HI Jos, I think that does not work, at least I never have. you can try this

plugins.jasperPluginRMI.runReport(server,'TakenMedewerker.jrxml','c:/temp/mypdf.pdf',OUTPUT_FORMAT.PDF,_params)

and than try: return plugins.file.readFile('c:/temp/mypdf.pdf')

ofcourse you should use the plugins.file.createTempFile, somewhere so you dont have to worry about the temp folder......

#2

Updated by Jos de Bruijn over 12 years ago

Hi Harjo,
That is indeed an option and it looks like i'm going to have to use it.
But if that is the case than the documentation and the sample code are not correct because both indicate that the runReport function returns a byte array with the content of the file:

      //The return value is a byte array with the content of the file generated that can be further used.
      //var res = plugins.jasperPluginRMI.runReport(currentcontroller.getServerName(),'samplereport.jrxml', null, OUTPUT_FORMAT.PDF, null);
      //plugins.file.writeFile('e:\\sample.pdf', res);

#3

Updated by Andrei Costache over 12 years ago

  • Status changed from New to Closed
  • Assignee set to Andrei Costache

Fixed.

Also available in: Atom PDF