The idea is to reuse a rest service, for 'n' template, but for this it is necessary to receive a parameter, in rest services I can obtain data from a certain user, and thus fill in the corresponding data in each template, each template represents a user and this pdf template, let's say a report is sent by email every client every so often through a shedule. In this way avoid generating a static template per client, but cunsumir the information of a rest service, just changing a parameter.
Posts made by jcvilladiegoc
-
RE: Parameterization of variables in beforeRender and afterRender script
-
Parameterization of variables in beforeRender and afterRender script
It is possible to define and send parameters from the template to the scripts that have functions berofeRender and afterRender, to send a parameter get, or path variable, and obtain different results, and thus in this way reuse the code in different templates by consulting the same api , and only change the value of the parameter in the template.
var getRequest = require('request').get function beforeRender(req, res, done) { getRequest('http://misitioweb/v1/data/user/', function (err, resp, body) { if (err) { return done(err) } req.data.user = JSON.parse(body).data done() }) }
-
Timeout server closed
The web server runs indefinitely or ends due to inactivity?
I had a project in windows and when it remained some time inactive it closed me ..
The file jsreport.config.json
{ "chrome" : { "timeout" : 40000 } }
I am interested in this being active
-
Duplicate emails
When using the service of sending emails of a pdf, it comes to me with a duplicate, that is, it is sent twice, and when making a different configuration, now it comes to me three times, it must be some configuration that is stored ... something like that...
function afterRender(req, res, done) { var mailer = require("nodemailer"); var smtpTransport = mailer.createTransport('smtps://jairo@midominio.co:password@smtp.midominio.com'); var mail = { from: "Mi persona <miusuario@midominio.co>", to: "miusuario@gmail.com", subject: "Test from jsreport", text: "Esto es un test", html: "<b>Esto es un test, parte 2. Veamos si me voy mas de una vez</b>", attachments: [ { filename: 'Reporte - {{ client.name }}.pdf', content: new Buffer(res.content) }], } smtpTransport.sendMail(mail, function(error, response){ smtpTransport.close(); if(error){ return done(error); } return done(); });
}
-
No puedo acceder a ninguna propiedad o funcion de document javascript en el editor de template inferior.
Hola, porque al momento de editar un template, en la parte inferior tengo para cargar javascript no puedo acceder a document, me sale que document no esta definido.
Hello, because when I edit a template, at the bottom I have to load javascript I can not access the document, I get that document is not defined.
Error while executing templating engine. document is not defined. Error on line 18:5. 16 | father = '<div class="container-heatmap">'; 17 | config = _config1; > 18 | element = document.getElementById(config.idElement); | ^ 19 | // element.innerHTML = 'Loading ... '; 20 | // element.className = 'container-heatmap'; 21 | color = config.color.split('(')[1].split(',')[0];
-
RE: Hola!, me sale un error al iniciar jsreport
Hola, si, me funciono correctamente y pude correr el proyecto, respalde los contents y cuando ya estaba funcionado, los volvi a crear y cargue nuevamene el contenido. Gracias!
Hello, yes, I worked correctly and could run the project, back the contents and when it was already working, I created them and loaded the content again. Thanks!
-
RE: Hola!, me sale un error al iniciar jsreport
Hola, otra información adicional es los archivos en los cuales estaba trabajando es en tamplate/Reporte, assets/Reporte.css, assets/Reporte.js, Reporte footer, Reporte header. Pude observar en los archivos que por cada elemento en assets hay una carpeta que contiene content.json y el archivo original por ejemplo content.css. Este ejemplo anterior para el caso del css no tiene valores en config.son. Quizas eliminando este archivo se pueda colocar en marcha de nuevo?
Hello, another additional information is the files in which I was working is in tamplate / Report, assets / Reporte.css, assets / Reporte.js, Footer Report, Report header. I could see in the files that for each element in assets there is a folder that contains content.json and the original file for example content.css. This previous example for the case of the css has no values in config.son. Maybe removing this file can be put back on track?
-
RE: Hola!, me sale un error al iniciar jsreport
Hola, sigue saliendo el mismo error, luego de haber eliminado el archivo setting de data. Justo en ese momento cuando se presento el fallo de energia estabá configurando propiedades en los margenes de chrome-pdf.
Hello, the same error is still coming out, after having deleted the setting data file. Just at that moment when the power failure was present, it was configuring properties in the chrome-pdf margins.
-
Hola!, me sale un error al iniciar jsreport
Hola!, me sale un error al iniciar jsreport. Estaba trabajando en el studio editor y tuve un fallo de energia. Cuando encendi e inicie el servidor con jsrepor start me sale el siguiente error
Hello! I get an error when starting jsreport. I was working in the studio editor and I had a power failure. When I started up and started the server with jsrepor start I get the following error
jsreport start 2018-09-05T17:05:56.206Z - info: Initializing jsreport@2.2.0 in development mode using configuration file: jsreport.config.json 2018-09-05T17:05:56.221Z - info: Searching for available extensions in /home/pi/jsreportapp/ 2018-09-05T17:05:56.369Z - info: Extensions location cache doesn't contain entry yet, crawling 2018-09-05T17:05:58.256Z - info: Found 31 extensions 2018-09-05T17:05:58.321Z - debug: Writing extension locations cache to /tmp/jsreport/core/locations.json 2018-09-05T17:05:58.327Z - debug: Discovered 31 extensions 2018-09-05T17:05:58.590Z - info: Setting process based strategy for rendering. Please visit http://jsreport.net/learn/configuration for information how to get more performance. 2018-09-05T17:05:58.629Z - info: Using extension handlebars 2018-09-05T17:05:58.656Z - info: Using extension import-export 2018-09-05T17:05:59.294Z - info: Using extension templates 2018-09-05T17:05:59.311Z - info: Using extension jsrender 2018-09-05T17:05:59.314Z - debug: Extension authentication is disabled, skipping 2018-09-05T17:05:59.315Z - info: Using extension freeze 2018-09-05T17:05:59.323Z - info: Using extension cli 2018-09-05T17:05:59.326Z - info: Using extension express 2018-09-05T17:05:59.904Z - info: Using extension debug 2018-09-05T17:05:59.913Z - info: Using extension tags 2018-09-05T17:05:59.929Z - info: Using extension data 2018-09-05T17:05:59.939Z - info: Using extension fs-store 2018-09-05T17:06:00.867Z - info: Using extension authorization 2018-09-05T17:06:00.878Z - debug: Extension authorization was disabled 2018-09-05T17:06:00.879Z - info: Using extension html-to-xlsx 2018-09-05T17:06:01.591Z - info: html-to-xlsx detected chrome as available html engine 2018-09-05T17:06:01.592Z - info: Using extension child-templates 2018-09-05T17:06:01.603Z - info: Using extension browser-client 2018-09-05T17:06:01.613Z - info: Using extension chrome-pdf 2018-09-05T17:06:01.655Z - info: Using extension pdf-utils 2018-09-05T17:06:01.663Z - info: Using extension version-control 2018-09-05T17:06:01.789Z - info: Using extension reports 2018-09-05T17:06:01.806Z - info: Using extension text 2018-09-05T17:06:01.810Z - info: Using extension base 2018-09-05T17:06:01.817Z - info: Using extension studio 2018-09-05T17:06:01.945Z - info: Using extension licensing 2018-09-05T17:06:02.017Z - info: Using extension scripts 2018-09-05T17:06:02.037Z - info: Using extension assets 2018-09-05T17:06:02.073Z - info: Using extension scheduling 2018-09-05T17:06:02.280Z - info: Using extension xlsx 2018-09-05T17:06:02.734Z - info: Using extension sample-template 2018-09-05T17:06:02.744Z - info: Using extension resources 2018-09-05T17:06:02.750Z - info: Using extension public-templates 2018-09-05T17:06:02.767Z - debug: Extension public-templates was disabled 2018-09-05T17:06:02.790Z - info: fs store is persisting using fs 2018-09-05T17:06:02.792Z - info: fs store is synchronizing using fs 2018-09-05T17:06:02.801Z - info: fs store is loading data 2018-09-05T17:06:02.867Z - error: Error occured during reporter init SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) at parse (/home/pi/jsreportapp/node_modules/jsreport-fs-store/lib/customUtils.js:77:15) at parseFiles (/home/pi/jsreportapp/node_modules/jsreport-fs-store/lib/persistence.js:25:18) at <anonymous> An error has occurred when trying to initialize jsreport (2). Unexpected end of JSON input (1). caused by error (2) -> stack = Error: at instance.init.then.catch (/home/pi/jsreportapp/node_modules/jsreport-cli/lib/instanceHandler.js:31:29) at <anonymous> caused by error (1) -> stack = SyntaxError: at JSON.parse (<anonymous>) at parse (/home/pi/jsreportapp/node_modules/jsreport-fs-store/lib/customUtils.js:77:15) at parseFiles (/home/pi/jsreportapp/node_modules/jsreport-fs-store/lib/persistence.js:25:18) at <anonymous>
-
RE: Chrome-pdf / Phantom-pdf en raspberry pi 3 ó OS Raspbian
Hola, ya me funcionó con chromium-browser
sudo apt-get install chromium-browser
Adicional a esto, seguirá saliendo un error, pero este se soluciona agregando esto en la configuración
{ "extensions": { "chrome-pdf": { "launchOptions": { "executablePath": './ruta/al-ejecutable/de-chrome-que-funciona-en-raspberry' }, "args": ["--no-sandbox"] } } }
Agregando la linea "args": ["--no-sandbox"] en la configuración chrome-pdf.
-
RE: Chrome-pdf / Phantom-pdf en raspberry pi 3 ó OS Raspbian
Hola, no pude instalar google-chrome-unstable porque no tiene un candidato para la instalación
// Chrome dependency Entrada :: sudo apt-get install -y libgconf-2-4 Entrada :: sudo wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - Entrada :: sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' Entrada :: sudo apt-get update Entrada :: sudo apt-get install -y google-chrome-unstable Salida :: Leyendo lista de paquetes... Hecho Salida :: Creando árbol de dependencias Salida :: Leyendo la información de estado... Hecho Salida :: E: No se ha podido localizar el paquete google-chrome-unstable
-
RE: Chrome-pdf / Phantom-pdf en raspberry pi 3 ó OS Raspbian
Hola! instale jsreport en una raspberry para generar unos reportes en pdf, los templates de ejemplo vienen con chrome-pdf, hice un template sencillo para probar con Phantom-pdf ya que no pude instalar google-chrome-unstable. tengo habilitado web server y accedo a este mediante http por el puerto 5488 y entro a http://host:5488/studio/template, instale la dependencia para usar phantomjs para renderizar pdf y me sale el siguiente error.
Error: Command failed: /home/pi/jsreportapp2/node_modules/phantomjs/lib/phantom/bin/phantomjs --ignore-ssl-errors=yes --web-security=false --ssl-protocol=any /home/pi/jsreportapp2/node_modules/phantom-html-to-pdf/lib/scripts/standaloneScript.js /tmp/jsreport/autocleanup/3b2c5ee5-76e8-4a09-8c50-d0de439d69ecsettings.html
/home/pi/jsreportapp2/node_modules/phantomjs/lib/phantom/bin/phantomjs: 1: /home/pi/jsreportapp2/node_modules/phantomjs/lib/phantom/bin/phantomjs: Syntax error: word unexpected (expecting ")")at ChildProcess.exithandler (child_process.js:275:12) at emitTwo (events.js:126:13) at ChildProcess.emit (events.js:214:7) at maybeClose (internal/child_process.js:925:16) at Socket.stream.socket.on (internal/child_process.js:346:11) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at Pipe._handle.close [as _onclose] (net.js:567:12)
-
Chrome-pdf / Phantom-pdf en raspberry pi 3 ó OS Raspbian
Hola a todos!
Como puedo configurar la dependencia chrome-pdf o phantom-pdf en un sistema operativo raspbian / raspberry pi 3?
He seguido las indicaciones siguientes https://jsreport.net/learn/ubuntu, pero aun no me ha funcionado, tengo la salidad HTML.