Page 1 of 1

Exporting report to PDF

Posted: Thu Jul 28, 2016 9:06 am
by Chris
Hello,

we are currently evaluating Stimulsoft Reports.PHP.

We got the basic functions up and running and are now trying to export a report to pdf
to a base64 encoded string which is then posted to a script that sends an email with the
pdf as attachment.

Our problem is that we can't convert the stream from the export to a correct base64 encoded string.
We've already tried several approaches but couldn't get it to run.

Any help would be highly appreciated.

Thanks in advance.

Re: Exporting report to PDF

Posted: Thu Jul 28, 2016 10:41 am
by HighAley
Hello, Chris.

Could you specify how you export the reports?
Do you use Flash or HTML components?

Thank you.

Re: Exporting report to PDF

Posted: Thu Jul 28, 2016 11:36 am
by Chris
Hello HighAley,

we're using the HTML components (lastest internal build).

Here's a excerpt of our code:

Code: Select all

var report = new Stimulsoft.Report.StiReport();
var dataSet = new Stimulsoft.System.Data.DataSet();
dataSet.readJson(data);
report.regData("Demo", "Demo", dataSet);
report.loadFile("reports/" + repname + ".mrt");
report.dictionary.synchronize();
report.render();
var settings = new Stimulsoft.Report.Export.StiPdfExportSettings();
var service = new Stimulsoft.Report.Export.StiPdfExportService();
var stream = new Stimulsoft.System.IO.MemoryStream();
service.exportTo(report, stream, settings);

// --- covert stream to base64 encoded string and post it to the server ---
// --- We're stuck here ... ---

The above code works as long as we save the export to the local computer like in
the samples, but converting the stream to a valid base64 representation of the pdf file
gives us headaches (base64 string is broken).

Thanks for your help.

Re: Exporting report to PDF

Posted: Thu Jul 28, 2016 9:46 pm
by Ivan
Hello, Chris.
... but converting the stream to a valid base64 representation of the pdf file gives us headaches (base64 string is broken).
Could you specify how you trying to convert the stream to a base64 representation ?

Thank you.

Re: Exporting report to PDF

Posted: Fri Jul 29, 2016 9:42 am
by Chris
Hello Ivan,

here' the code of one of our tries to convert the stream to base64 string:

Code: Select all

var sr = new Stimulsoft.System.IO.StreamReader(stream);
var r = true;
var cont = '';
while(r == true) {
    var l = sr.readLine();
    if(l != null) {
         cont = cont + l;
    } else {
         r = false;
    }
}
var basesixtyfour = Base64.encode(cont);
Thanks for your help.

Re: Exporting report to PDF

Posted: Tue Aug 02, 2016 3:05 pm
by HighAley
Hello, Chris.

Please try to use the following code:

Code: Select all

service.exportTo(report, stream, settings); 
var bytes = stream.toArray();
var base64 = Stimulsoft.System.Convert.toBase64String(bytes);
Thank you.

Re: Exporting report to PDF

Posted: Thu Aug 11, 2016 11:45 am
by Chris
Hello HighAley,

thanks for the sample code.
Unfortunately our problem persists also with this approach.
At least we managed to narrow it down a little bit:
The issue seems to be image related - as soon as we got an image inside the report (a png in our case)
the bas64 string seems to be broken. When we remove the image everything works as expected.

Any suggestions are highly appreciated.
Thanks.

Re: Exporting report to PDF

Posted: Thu Aug 11, 2016 2:46 pm
by HighAley
Hello.

Do you get the issue with any image?
Could you send us a sample of such report with and without image?

Thank you.