These are chat archives for jsreport/jsreport

19th
Jan 2018
Ry Blaisdell
@rylincoln
Jan 19 18:27
hi - having some issues both with browser jsreport.render and jsreport.renderAsync -
with jsreport.render we sometimes run into the too many parameters limitation(this is browser lmiit and not jsreport limit yes?)
with jsreport.renderAsync sometimes the returned report (pdf as binary text??) - sometimes it loads fine but if the report is too big it gets into the browser but not into the div where we tell it to go . - can show you if anyone has time to take a quick look. @jkyoungchoi is working on this now trying to figure out way to make it work.
Downloading the pdf works fine btw. just rendering it in browser is sometimes having an issue
rfid
@jkyoungchoi
Jan 19 19:22
image.png
Adding a screenshot along with @rylincoln message.
BJR Matos
@bjrmatos
Jan 19 19:24
hi! can you paste what is the exact error message (if any) that you are getting in the browser?
i think the problem is that browsers can’t handle big reports when loading a pdf from a long data uri string (like the present in the above picture)
rfid
@jkyoungchoi
Jan 19 19:27
It has no error messages, when PDF(return) has less than a couple of photos, it renders just fine. It won't display it when it has more photos.
BJR Matos
@bjrmatos
Jan 19 19:27
how big is the pdf file?
(download it and see the size)
rfid
@jkyoungchoi
Jan 19 19:27
about 3~5 MB
By the way downloading works just fine
BJR Matos
@bjrmatos
Jan 19 19:28
yes, the issue is browser display
but i have a workaround.. you are using renderAsync from browser sdk, right?
rfid
@jkyoungchoi
Jan 19 19:29
One that does not display is 2.79 Mb
yes I'm using renderAsync from browser sdk
Ry Blaisdell
@rylincoln
Jan 19 19:30
oh cool we have some feedback from @bjrmatos !
BJR Matos
@bjrmatos
Jan 19 19:30
ok, i’m not sure if the problem is about long data uri but let’s try something..
hi @rylincoln let’s see if i can help :D
Ry Blaisdell
@rylincoln
Jan 19 19:31
:wave:
BJR Matos
@bjrmatos
Jan 19 19:31
open this file in your jsreport project
node_modules/jsreport-browser-client-dist/jsreport.js
Ry Blaisdell
@rylincoln
Jan 19 19:33
in the server where we install jsreport?
rfid
@jkyoungchoi
Jan 19 19:33
ok
BJR Matos
@bjrmatos
Jan 19 19:33
yes
Ry Blaisdell
@rylincoln
Jan 19 19:33
k one second gotta remote into host and bash into docker
BJR Matos
@bjrmatos
Jan 19 19:34
ok, i also need some code where you are using the browser sdk renderAsync so i can help in updating it
Ry Blaisdell
@rylincoln
Jan 19 19:34
k
@jkyoungchoi can you paste our code from the renderAsync function here?
rfid
@jkyoungchoi
Jan 19 19:35
jsreport.renderAsync(request).then(function(r) {
                pdfURI = r.toDataURI();
              $('#pdf_object').attr('data',pdfURI)
              $('#pdfModal').on('hidden.bs.modal', function () {
                    $('#pdf_object').attr('data','');
                });
                $("#pdfModal").modal("show");
                $("#downloadPDF-btn").click(function() {
                    r.download('report.pdf')
                });
            });
BJR Matos
@bjrmatos
Jan 19 19:36
ok i see, you are creating the object tag by yourself, right?
rfid
@jkyoungchoi
Jan 19 19:37
right, is there other way to get the pdf?
BJR Matos
@bjrmatos
Jan 19 19:37
yes, will share in a moment
@rylincoln when you have located the node_modules/jsreport-browser-client-dist/jsreport.js file please replace it with this
Ry Blaisdell
@rylincoln
Jan 19 19:38
i'm inside the docker now and have jsreport.js file accessible
BJR Matos
@bjrmatos
Jan 19 19:38
Ry Blaisdell
@rylincoln
Jan 19 19:38
ok
rfid
@jkyoungchoi
Jan 19 19:39
gonna give a shot
Ry Blaisdell
@rylincoln
Jan 19 19:39
?
BJR Matos
@bjrmatos
Jan 19 19:39
you will need that updated source code in order to follow my next solution
Ry Blaisdell
@rylincoln
Jan 19 19:39
i'll replace that jsreport.js file
in docker @jkyoungchoi
update source code sounds ... fun :)
rfid
@jkyoungchoi
Jan 19 19:45
So far, no errors, but acting same. Displaying only smaller URI
BJR Matos
@bjrmatos
Jan 19 19:45
yes, the real solution is next.. (i’m writing it at the moment)

please first make #pdf_object element an empty div in your html instead of a object tag

then use this code to render a report:

jsreport.renderAsync(request).then(function(r) {
             var iframe = document.createElement('iframe')
              var objectUrl = r.toObjectURL()
              $('#pdf_object’).empty();

iframe.src = objectUrl;
iframe.style.width = '100%'
iframe.style.height = '100%'

$('#pdf_object’).append(iframe);

              $('#pdf_object’).show();
              $('#pdfModal').on('hidden.bs.modal', function () {
                                  $('#pdf_object’).hide();
                });
                $("#pdfModal").modal("show");
                $("#downloadPDF-btn").click(function() {
                    r.download('report.pdf')
                });
            });
Ry Blaisdell
@rylincoln
Jan 19 19:51
i still owe you serveral :beers: @bjrmatos
rfid
@jkyoungchoi
Jan 19 19:51
@bjrmatos It worked!!
Thanks a lot!
BJR Matos
@bjrmatos
Jan 19 19:53
yes!
now the jsreport.js file that i gave to you
i will chat with @pofider to include it in next release
rfid
@jkyoungchoi
Jan 19 19:54
sounds great!
BJR Matos
@bjrmatos
Jan 19 19:58
ok, perfect. gald that i was able to help you
rfid
@jkyoungchoi
Jan 19 20:29
@bjrmatos 👍
Ry Blaisdell
@rylincoln
Jan 19 20:31
@bjrmatos when you coming to visit Austin? (maybe when we get rid of chief cheeto?)
BJR Matos
@bjrmatos
Jan 19 20:32
hahah
hopefully someday, traveling is a very relaxing thing so let’s see :D
Ry Blaisdell
@rylincoln
Jan 19 21:54
:thumbsup: