Images not appearing when saved as PDF

Stimulsoft Reports.JS discussion
Post Reply
richierich
Posts: 14
Joined: Wed Jun 19, 2013 9:12 am

Images not appearing when saved as PDF

Post by richierich »

I have a report which I created using the JavaScript stiDesigner control, and when I view it from within the designer (preview) or directly from the stiViewer, the images appear fine. I'm using the image control, and a hyperlink which points to a field containing the URL.

As I said, this appears fine within the Stimulsoft viewer, but when I 'Save as PDF' the images just appear as a grey square.

I've seen a few other posts which suggest using renderAsync() but I'm not using code to render this, I'm just using the built-in "Save as PDF". Also if I print, it's the same.

I'm using

Version 2020.1.2 from 17 January 2020, PHP, JS

Can you suggest how I can get this working please?
Lech Kulikowski
Posts: 6238
Joined: Tue Mar 20, 2018 5:34 am

Re: Images not appearing when saved as PDF

Post by Lech Kulikowski »

Hello,

Please send us a sample report with test data that reproduces the issue for analysis.

Thank you.
grbspltt
Posts: 25
Joined: Fri Apr 28, 2017 2:50 pm

Re: Images not appearing when saved as PDF

Post by grbspltt »

I'm having the same issue, been banging my head against the wall for hours on this. Glad to see its not just me.

See attached sample.
Attachments
Demo-Blank-PDF-Node.zip
(121 KiB) Downloaded 157 times
Lech Kulikowski
Posts: 6238
Joined: Tue Mar 20, 2018 5:34 am

Re: Images not appearing when saved as PDF

Post by Lech Kulikowski »

Hello,

We need some additional time to investigate the issue, we will let you know about the result.

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

Re: Images not appearing when saved as PDF

Post by Lech Kulikowski »

Hello,

1. you write about a picture from Url, and in the example you have a picture from resources. they have different behavior.
2. please send the original image you have in your report for analysis. We can't figure out what format it is.
3. you write "I'm not using code to render this" but in the example the report is rendered and exported from the code.

Below is your corrected code of how to export correctly:

Code: Select all

report.renderAsync(function () {
  var data = report.exportDocumentAsync(function(buf) {

  var buffer = new Buffer(buf, "utf-8");
  var fs = require("fs");
  fs.writeFileSync("Report.pdf", buffer);
}, Stimulsoft.Report.StiExportFormat.Pdf); }).
this code works correctly

Thank you.
richierich
Posts: 14
Joined: Wed Jun 19, 2013 9:12 am

Re: Images not appearing when saved as PDF

Post by richierich »

Hello.

I think the confusion is because it was a different user that said they're having the same issue, and THEY posted an example.

I already mentioned that I'm using the built in "Save as PDF", I'm not rendering in code..

Rich
Lech Kulikowski
Posts: 6238
Joined: Tue Mar 20, 2018 5:34 am

Re: Images not appearing when saved as PDF

Post by Lech Kulikowski »

Hello,

If an image is loaded via URL from JS code, the console will get this kind of error:
"Access to XMLHttpRequest at 'https://.......png' from origin 'https://......' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

It is described for example here:
https://developer.mozilla.org/en-US/doc ... llowOrigin

To upload an image from another domain, you must first give permission to upload from this domain.
In the preview the picture is loaded by the browser itself, it does not need permission, so the picture is displayed.
To export it to pdf you need to upload it from code to embed it in pdf.

Thank you.
Post Reply