Exporting report to PDF

Stimulsoft Reports.PHP discussion
Post Reply
Chris
Posts: 5
Joined: Thu Jul 28, 2016 8:49 am

Exporting report to PDF

Post 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.
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Exporting report to PDF

Post by HighAley »

Hello, Chris.

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

Thank you.
Chris
Posts: 5
Joined: Thu Jul 28, 2016 8:49 am

Re: Exporting report to PDF

Post 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.
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

Re: Exporting report to PDF

Post 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.
Chris
Posts: 5
Joined: Thu Jul 28, 2016 8:49 am

Re: Exporting report to PDF

Post 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.
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Exporting report to PDF

Post 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.
Chris
Posts: 5
Joined: Thu Jul 28, 2016 8:49 am

Re: Exporting report to PDF

Post 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.
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Exporting report to PDF

Post 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.
Post Reply