Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Could not create class net.sf.jasperreports.engine.data.JsonDataSource #57

Open
SrilakshmiGodugunuri7 opened this issue Dec 14, 2020 · 3 comments

Comments

@SrilakshmiGodugunuri7
Copy link

No description provided.

@dcsline
Copy link

dcsline commented Jun 19, 2021

This is my tested content for sample.js 👍

@dcsline
Copy link

dcsline commented Jun 19, 2021

var fs = require('fs');

var jasper = require('node-jasper')({
path: '../lib/jasperreports-5.6.0',
reports: {
stock_ofertas: {
jasper: __dirname + '/sample.jasper',
jrxml: __dirname + '/sample.jrxml',
conn: 'in_memory_json'
}
}
});

jasper.ready(function() {
var r = jasper.export(
{
report: 'stock_ofertas',
data: {
language: 'spanish',
// on jasper make a parameter named "dataset2" and use on a subreport:
// ((net.sf.jasperreports.engine.data.JsonDataSource)$P{dataset2})
dataset2: jasper.toJsonDataSource(
{
dados: [{ value: 1, value: 2 }]
},
'dados'
)
},
dataset: [
{
name: 'Gonzalo',
lastname: 'Vinas' // TODO: check on UTF-8
},
{
name: 'Agustin',
lastname: 'Moyano'
}
]
},
'pdf'
);

//fs.writeFile(__dirname + '/sample.pdf', r);
fs.writeFile(__dirname+ '/sample.pdf', r, (error)=>{
    if(error) console.log(error);
})

});

@leftundersun
Copy link

To make it works, I needed to move the lib folder from dist to root. Sometimes he complains about fonts, but i just changed all to some that works and it goes fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants