agmoyano / node-jasper

JasperReports from Node.js
84 stars 52 forks source link

but could a more detailed explanation of how to put Jasper Report library in the project directory nodejs? #38

Closed martinmurciego closed 5 years ago

martinmurciego commented 6 years ago

I tried again to configure this module after a long time and I do not understand it. You closed the issue but in reality did not finish understanding and resolving. It is true that you must allow a relative path as other options. But I can not configure it.

https://github.com/agmoyano/node-jasper/issues/28#issuecomment-402481553

var options = {
  path: './lib/jasperreports-6.7.0/', //Path to jasperreports-x.x.x directory (from jasperreports-x.x.x-project.tar.gz)
  reports: {
    // Report Definition
    "name": {
      jasper: './reports/', //Path to jasper file,
      jrxml: './reports/', //Path to jrxml file,
      conn: false, //Connection name, definition object or false (if false defaultConn won't apply or if ´in_memory_json´ then you can pass an JSON object in the ´dataset´ property for in-memory data sourcing instead of database access

    }
  },
  drivers: {
    // Driver Definition
    "name": {
      path: './bin/jdbc/postgresql-42.2.1.jar',//postgresql-42.2.1.jre7.jar //Path to jdbc driver jar
      class: 'org.postgresql.Driver', //Class name of the driver (what you would tipically place in "Class.forName()" in java)
      type: 'postgres'//Type of database (mysql, postgres)
    }
  },
  conns: {
    // Connection Definition
    "name": {
      host: 'localhost', //Database hostname or IP
      port: '5433', //Database Port
      dbname: 'centro_convenciones', //Database Name
      user: 'postgres', //User Name
      pass: 'admin', //User Password
      jdbc: 'jdbc:postgresql://localhost:5433/centro_convenciones', //jdbc connection String. If this is defined, every thing else but user and pass becomes optional.
      driver: 'postgresql'//name or definition of the driver for this conn
    }
  },
  defaultConn: 'pgConvenciones',//Default Connection name
  java: '',//Array of java options, for example ["-Djava.awt.headless=true"]
  javaInstnace: null//Instance of node-java, if this is null, a new instance will be created and passed in 'java' property
 };
var jasper = require('node-jasper')(options);

The path to the jasper report library directory unnziped within the project is: /app-sample/lib/jasperreports-6.7.0/dist

agmoyano commented 5 years ago

Hello, sorry you had trouble.. have you tried like this?

const path = require('path');

let options {
    path: path.join(__dirname, 'lib','jasperreports-6.7.0'),

this is assuming your index file, where this configuration is, is located in

/home/username/project/index.js

and your jasperreports is in

/home/username/project/lib/jasperreports-6.7.0

Regards.

IrfanMurtaza93 commented 5 years ago

I'm also having trouble while putting the library path. Can you please elaborate it?

agmoyano commented 5 years ago

Hello Ifran, as I said before, if your index is in

/home/username/project/index.js

and your jasperreports is in

/home/username/project/lib/jasperreports-6.7.0

you should place

const path = require('path');

let options {
    path: path.join(__dirname, 'lib','jasperreports-6.7.0'),

in your index.js

What kind of trouble are you having, specifically?

HashamSS commented 4 years ago

Hello @agmoyano can you please explain what path you needed ? I have jasper report installed on my computer but still didnt get the way how can I fix this issue

martinmurciego commented 4 years ago

This was the first project I came across several years ago but I never knew how to configure it to work. One that if it worked for me and I am uploading with the included libraries you can find it in my repository that a fork with the libraries as I told you: https://github.com/martinmurciego/node-jasper-server

Original: https://github.com/andrewloable/node-jasper-server