I sent you an email.
Posts made by Matthew Ward
-
Increase Online Limits
Would it be possible to set up a separate billing price if I wanted to increase the account limits for jsreportonline?
For example, timeout times, parallel render requests etc.? -
RE: Download pdf or xlsx response so that I can email it.
I figured it out.
var file = res.toDataURI();
That gives me the base64 encoded pdf in a string. So, once I put that in the variable I just did an ajax call in javascript where I then handle the rest in .php.
$f = str_replace('data:application/pdf;base64,', '', $f);
file_put_contents( EMAIL_ATTACHMENTS .$file, $f);
$fp = fopen(EMAIL_ATTACHMENTS . $file, 'wb');
fwrite($fp, base64_decode($f));
fclose($fp);That saves the pdf to the attachments file where I temporarily store the file to attach to emails using sendgrid.
-
Download pdf or xlsx response so that I can email it.
Quick background. I'm using jsreportonline. I'm creating a bunch of custom templates on the fly based off various user data. I'm doing all of this in JavaScript as the whole program is client-side. So, all of the solutions that use NodeJS are no good. I am currently viewing the pdf in a new window where the user can download it. Now, if the user wants to email the file I think my best bet is to download the file temporarily then attach that file and email it over sendgrid like I do normally. But I can't find a way to save the file to a specific path instead of downloading it to the computer in the browser.
This is my current code to view the pdf. Any direction on where to go from here on downloading the pdf so I can email it.
var request = { template: { content: header + contentString, name: "invoice-main", engine: engine, recipe: recipe, helpers: helpers, chrome: { landscape: isLand, marginTop: '20px', marginRight: '20px', marginBottom: '20px', marginLeft: '20px' }, reports: { save: true } }, data: aa }; jsreport.renderAsync(request).then(function(res) { console.log( "in async...." ); var html = '<html>' + '<style>html,body {padding:0;margin:0;} iframe {width:100%;height:100%;border:0}</style>' + '<body>' + '<iframe type="application/pdf" src="' + res.toDataURI() + '"></iframe>' + '</body></html>'; var a = window.open( "" , "", "wReport', top=2, left=2, " + "toolbar=no, menubar=no, location=1, height=900, " + "width=960, scrollbars=yes" ); a.document.write(html); a.document.title = title; a.onload = function() { parent.close(); } a.document.close(); })
-
RE: API Timeout | JsReportOnline
I can't find any way to get the header "JO-Credits-Spent".
-
RE: API Timeout | JsReportOnline
Do you have an example of getting that? I keep getting "undefined" when I try a few different ways to access the response header.
My code looks like this..
jsreport.renderAsync(request).then(function(res) { console.log( "in async...." ); var html = '<html>' + '<style>html,body {padding:0;margin:0;} iframe {width:100%;height:100%;border:0}</style>' + '<body>' + '<iframe type="application/pdf" src="' + res.toDataURI() + '"></iframe>' + '</body></html>'; var a = window.open("about:blank", "Report") a.document.write(html) a.document.close();
-
RE: API Timeout | JsReportOnline
I talked to my boss about this. The 1000s throttle could also be an issue. If we had 300 users submit a request for a report within 5 minutes it would be an issue. Is the 1000s throttle something that could be changed? We might be able to live with the timeout issue.
Another question is since I am using the API is there a way to know how many credits a report is using? I'd like to have that value returned somehow so I can store it.
-
API Timeout | JsReportOnline
I am currently using the API for JsReport Online.
There is a 20s timeout for chrome-pdf and a 10s timeout for html-to-xlsx.
I'm using the free version right now for development but when this goes into production we were thinking we would AT LEAST need the silver $100 per month subscription. If we move off of the free version will that help with the timeout times?It's a school software so in the example of a school printing something that involves all the students the 20s timeout is not enough. Plus multiple users could be queering at the same time.
-
RE: Easier way to define helper functions?
I am using the api. Is there a way to edit that configuration for the api?
-
Easier way to define helper functions?
I am using data that will be generated by the user and creating the html and passing it as a string in "content" on my request. I am testing out helper functions to total amounts in this example. I can't seem to get my helper function to work any other way than as shown in the code.
$sayReport .= '
<div>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/metro/4.1.5/css/metro.min.css"><table class=\'table striped\'> <thead> <tr> <th></th> <th>ID</th> <th>Last Name</th> <th>First Name</th> <th>Last Pmt Amt</th> <th>Birthday</th> <th>Gender</th> </tr> </thead> <tbody> {{for array}} <tr> <td></td> <td>{{:id}}</td> <td>{{:lastName}}</td> <td>{{:firstName}}</td> <td>{{:lastPmtAmt}}</td> <td>{{:birthdate}}</td> <td>{{:gender}}</td> </tr> {{/for}} <tr> <td style="font-weight: bold; text-decoration: underline;">{{:array.length}}</td> <td style="font-weight: bold; text-decoration: underline;"></td> <td style="font-weight: bold; text-decoration: underline;"></td> <td style="font-weight: bold; text-decoration: underline;"></td> <td style="font-weight: bold; text-decoration: underline;">{{:~mySumFunction(array)}}</td> </tr> </tbody> </table> <div style=\'page-break-after: always;\'> </div>
</div>
';
function renderReport()
{// Client var request = { template: { name: 'invoice-main', engine: 'jsrender', recipe: 'chrome-pdf', content: contentString, helpers: "function mySumFunction(aa) {\n" + " var total = 0;\n" + " for(var i = 0; i < aa.length; i++)\n" + " {\n" + " total += parseFloat(aa[i]['lastPmtAmt']);\n" + " }\n" + " return '$' + total;\n" + " }" }, data: aa, }; console.log( "Request made!" ); var reportDisplay = document.getElementById("report-display"); reportDisplay.innerHTML = ""; jsreport.renderAsync(request).then(function(res) { console.log( "in async...." ); var html = '<html>' + '<style>html,body {padding:0;margin:0;} iframe {width:100%;height:100%;border:0}</style>' + '<body>' + '<iframe type="application/pdf" src="' + res.toDataURI() + '"></iframe>' + '</body></html>'; console.log( "before open...." ); var a = window.open("about:blank", "Report") console.log( "before write...." ); a.document.write(html) a.document.close() console.log( "done!" ); }) return "REPORT LOADED"; }
I think I saw somewhere that you can do something like this but this gives me errors when adding myhelpers to the template request:
function mySumFunction(aa) { var total = 0; for(var i = 0; i < aa.length; i++) { total += parseFloat(aa[i]['lastPmtAmt']); } return '$' + total; }
var myhelpers = {mySumFunction: mySumFunction()};
-
RE: Getting jsreport implemented in an existing production environment.
For some reason it said I didn't have permission to add pictures to the actual post. So here is this.
-
Getting jsreport implemented in an existing production environment.
I am new to jsreport and don't see much documentation for setting up and using jsreport for anything not being developed using the jsreport studio. I have installed, initialized, and configured jsreport on my server (NOT local). I see the server.js file and the corresponding configuration files and I have read seemingly every bit of documentation that I think pertains to my issue.
Ultimately I am simply trying to use jsreport in any one of my .js files to render reports through jsreport-browser-client-dist.
I am basically trying to get the following line of code to not give a "jsreport is not defined" error
"jsreport.serverUrl = 'https://xxxxxxx.jsreportonline.net/api/report';"Additionally, since this will all occur in the browser I can't require('jsreport') without getting a "require is not defined" error.
Any actual code examples that are implementing jsreport into their program not using the studio would be really helpful!
-
RE: jsreport: command not found
Thank you! That was it I just had to add that path to $PATH
-
jsreport: command not found
I am currently trying to install jsreport on my beta server. I am running into an issue right out of the gate. I am following the installation process found here and also here. Node is installed and is a version that should be compatible. Are there any other prerequisites that I need in order for the installation to work smoothly?