Saving PDF report server side in C#

Stimulsoft Reports.JS discussion
Post Reply
reeax
Posts: 11
Joined: Tue Dec 05, 2017 7:29 pm

Saving PDF report server side in C#

Post by reeax »

Hi,

I have some strange results when trying to save the report generated using Reports.JS on server (C#). The PDF is indeed created, but the layout is (letter spacings, etc..) is dysfunctional.

This is the JS code to get the report data:

Code: Select all

                    var settings = new Stimulsoft.Report.Export.StiPdfExportSettings();
                    var service = new Stimulsoft.Report.Export.StiPdfExportService();
                    var stream = new Stimulsoft.System.IO.MemoryStream();
                    service.exportTo(that.report, stream, settings);
                    var data = stream.toArray();
                    var sendToServer = JSON.stringify(data);
On the server I use this code to create the PDF

Code: Select all

                String[] _reportS = JsonConvert.DeserializeObject<String[]>(sendToServer);
                byte[] _reportB = _reportS.Select(byte.Parse).ToArray();
                File.WriteAllBytes(System.Web.HttpContext.Current.Server.MapPath("~/foo.pdf"), _reportB);
The PDF is created, and I can open it in Adobe Reader, but the layout is weird as I indicated before. Please advise.

Thanks

PS I don't want to use the client side JS function to save the file, it has to be done server-side.
reeax
Posts: 11
Joined: Tue Dec 05, 2017 7:29 pm

Re: Saving PDF report server side in C#

Post by reeax »

After a lot of trials, I managed to isolate the issue: it is 2 lines of CSS that completely break your report's PDF rendering!

If you add (as I did)

Code: Select all

        body {
            display: flex;
            flex-direction: column;
        }
the viewer looks fine, but the pdf export is completely destroyed (I can send you screenshots if needed). This is a bug that should be corrected in your future updates
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Saving PDF report server side in C#

Post by HighAley »

Hello.

Please, check the Can Grow property of the components.
If you still get the issue, send us your report template with sample data.

Thank you.
reeax
Posts: 11
Joined: Tue Dec 05, 2017 7:29 pm

Re: Saving PDF report server side in C#

Post by reeax »

Hello as I just told before, simply setting html body with flex css attribute breaks your report pdf rendering. Nothing to do with can grow property - up to you to update your codebase. For me it's ok now that I know what's this about.
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Saving PDF report server side in C#

Post by HighAley »

Hello.

Sorry, we didn't understand you before.
We have reproduced the issue.
We couldn't find the cause of this issue long time.
We are working on it.

Thank you.

Ticket reference: #5516.
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Saving PDF report server side in C#

Post by HighAley »

Hello.

We have made an improvement.
Please, check our next build that will be available next week.
If you still get the issue, please, check that the report is rendered inside of the BODY.
Or it should be rendered when the style for body is loaded.

Thank you.
Post Reply