Page 1 of 2

No images when creating PDF

Posted: Thu Nov 07, 2024 12:37 am
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

Re: No images when creating PDF

Posted: Fri Nov 08, 2024 9:53 am
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.

Re: No images when creating PDF

Posted: Fri Nov 08, 2024 3:49 pm
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.

Re: No images when creating PDF

Posted: Mon Nov 11, 2024 5:32 pm
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

Re: No images when creating PDF

Posted: Mon Nov 11, 2024 10:24 pm
by rjorge99
Thank you.

Re: No images when creating PDF

Posted: Tue Nov 12, 2024 9:40 am
by Lech Kulikowski
Hello,

You are welcome.

Re: No images when creating PDF

Posted: Fri Nov 15, 2024 8:28 am
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.

Re: No images when creating PDF

Posted: Tue Nov 19, 2024 2:43 pm
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);

Re: No images when creating PDF

Posted: Tue Nov 19, 2024 5:02 pm
by Lech Kulikowski
Hello,

Thank you for sharing your experience with other users.

Re: No images when creating PDF

Posted: Fri Jun 27, 2025 1:41 pm
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