No images when creating PDF

Stimulsoft Reports.JS discussion
rjorge99
Posts: 36
Joined: Tue Feb 28, 2023 6:24 pm

No images when creating PDF

Post by rjorge99 »

Hi,

I need to save a report on the server side as a PDF.

For that I use the next code with javascript:

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(report, stream, settings); 
var data = stream.toArray();
let reportDataToServer = JSON.stringify(data);
After stringified the stream, I send that to the server, and I create PDF using C#

Code: Select all

var reportS = JsonConvert.DeserializeObject<String[]>(reportData);
var reportB = reportS.Select(byte.Parse).ToArray();
var randomcode = Utils.RandomString(10);

var path = ....
File.WriteAllBytes(path, reportB);


The problem that I have, as you can see on the example I attach ("ImageBar1.png"), the report has images that are used as "Headers" , that because I need to have some border radius on the upper corners.

After creating the report with the steps I mentioned, the PDF is not showing the images as you can see in the image "NoBars.jpg".

What do i need to solve this problem, or whats the correct way to save the report in an specific path in the server.

Im using Reports.JS.

Thanks
Attachments
Report.zip
(5.07 MiB) Downloaded 166 times
NoBars.jpg
NoBars.jpg (65.02 KiB) Viewed 6204 times
ImageBar1.png
ImageBar1.png (43.21 KiB) Viewed 6204 times
Lech Kulikowski
Posts: 7287
Joined: Tue Mar 20, 2018 5:34 am

Re: No images when creating PDF

Post by Lech Kulikowski »

Hello,

We couldn't reproduce the issue on our samples.
Please send us a sample project that we can run and reproduce the issue.

Thank you.
Attachments
Screenshot 2024-11-08 105206.png
Screenshot 2024-11-08 105206.png (230.02 KiB) Viewed 6184 times
rjorge99
Posts: 36
Joined: Tue Feb 28, 2023 6:24 pm

Re: No images when creating PDF

Post by rjorge99 »

Hi,

I attach a basic example of what we need to do.

We need to save de pdf on the server side, because we need to send an email with that report attached.

Thanks.
Attachments
GenerateReporte.zip
(45.33 MiB) Downloaded 165 times
Lech Kulikowski
Posts: 7287
Joined: Tue Mar 20, 2018 5:34 am

Re: No images when creating PDF

Post by Lech Kulikowski »

Hello,

We require more time to investigate the issue thoroughly. Rest assured, we will keep you informed about the outcome as soon as possible.

Thank you.
#15981
rjorge99
Posts: 36
Joined: Tue Feb 28, 2023 6:24 pm

Re: No images when creating PDF

Post by rjorge99 »

Thank you.
Lech Kulikowski
Posts: 7287
Joined: Tue Mar 20, 2018 5:34 am

Re: No images when creating PDF

Post by Lech Kulikowski »

Hello,

You are welcome.
Lech Kulikowski
Posts: 7287
Joined: Tue Mar 20, 2018 5:34 am

Re: No images when creating PDF

Post by Lech Kulikowski »

Hello,

Only async methods work for exports with pictures, it needs to convert pictures:
exportToAsync(onExport: Function, report: StiReport, stream: MemoryStream, settings: StiExportSettings)
exportTo2(report: StiReport, stream: MemoryStream, settings: StiExportSettings): Promise<void>

Thank you.
rjorge99
Posts: 36
Joined: Tue Feb 28, 2023 6:24 pm

Re: No images when creating PDF

Post by rjorge99 »

Hi,

It worked great. Thanks.

In case anyone needs to export and save on the server, the code I used at the end :

Javascript Code

Code: Select all

var settings = new Stimulsoft.Report.Export.StiPdfExportSettings(); 
var service = new Stimulsoft.Report.Export.StiPdfExportService(); 
var stream = new Stimulsoft.System.IO.MemoryStream(); 
await service.exportTo2(report, stream, settings); 
var data = stream.toArray();
let reportData = JSON.stringify(data);


C# Code

Code: Select all

var reportS = JsonConvert.DeserializeObject<String[]>(reportData);
var reportB = reportS.Select(byte.Parse).ToArray();

var path = ....
File.WriteAllBytes(path, reportB);
Lech Kulikowski
Posts: 7287
Joined: Tue Mar 20, 2018 5:34 am

Re: No images when creating PDF

Post by Lech Kulikowski »

Hello,

Thank you for sharing your experience with other users.
mounteide
Posts: 1
Joined: Fri Jun 27, 2025 1:35 pm

Re: No images when creating PDF

Post by mounteide »

Hello:

I'm trying to generate the pdf and I can't open it.

First I create a custom button

Code: Select all

 createCustomButton(3, "TDC Mail", "/assets/img/logo-tdcmail-64px.png", function(){
    viewer.onEmailReport({
      format: 'pdf',
      fileName: report.reportAlias,
      data: GetDocumentExported('pdf'),
      accion: '1'
    });
  });
Then call this function to handle the report type

Code: Select all

 function GetDocumentExported(formato) {
    var data;
    switch (formato.toUpperCase()) {
      case 'PDF':
        data = createtPdf(report);
        break;

      case 'PPT2007':
        data = createPpt(report);
        formato = 'ppt';
        break;

      case 'HTML':
        data = createHtml(report);
        break;

      case 'TEXT':
        data = createTxt(report);
        formato = 'txt';
        break;

      case 'WORD2007':
        data = createDocx(report);
        formato = 'docx';
        break;

      case 'ODT':
        data = createOdt(report);
        break;

      case 'EXCEL2007':
        data = createXlsx(report);
        formato = 'xlsx';
        break;

      case 'ODS':
        data = createOds(report);
        break;

      case 'CSV':
        data = createCsv(report);
        break;

      case 'IMAGESVG':
        data = createSvg(report);
        formato = 'svg';
        break;
    }
    return data;
  }
Finally, if it is a PDF, call this last function.

Code: Select all

  async function createtPdf(report) {
    // Create an PDF settings instance. You can change export settings.

    var settings = new Stimulsoft.Report.Export.StiPdfExportSettings();
    var service = new Stimulsoft.Report.Export.StiPdfExportService();
    var stream = new Stimulsoft.System.IO.MemoryStream();
    await service.exportTo2(report, stream, settings);
    //service.exportTo(report, stream, settings);
    var data = stream.toArray();
    return data;
  }
The PDF is generated incorrectly, since I can't even open it.

What am I doing wrong?

Thanks in advance
Post Reply