Issues Adding Images as Resources via NodeJS API

Stimulsoft Reports.JS discussion
Post Reply
dbyzero
Posts: 1
Joined: Thu Jun 12, 2025 10:49 pm

Issues Adding Images as Resources via NodeJS API

Post by dbyzero »

Hello everyone,

I’ve been stuck on an issue for several days and I’m hoping someone here can help.

Context

I’m working with Stimulsoft Reports.JS and trying to add an image as a resource to my report using NodeJS.
Here’s the code I’m using to add my image:

Code: Select all

async function addImageResource(report, resourceName, imageUrl) {
    const base64 = fs.readFileSync('./logo.png').toString('base64');
    var resource = new Stimulsoft.Report.Dictionary.StiResource(
        resourceName, // name
        resourceName, // alias
        null, // not a file
        Stimulsoft.Report.Dictionary.StiResourceType.Image, // type
        base64, // base64 image data (no prefix)
        false
   );

    report.dictionary.resources.add(resource);
    console.log('Add resource ' + resource);
}
In my report template, I set the image URL to resource://logo2.

The Problem

  • * After adding the resource, I notice that my resource object has a _content property instead of _packAndEncryptContent.
    * When I render the report, the image doesn’t display properly. Instead, I get a gray square.
    * I’ve seen that some Stimulsoft resource images have a _packAndEncryptContent property instead of _content.
    * My guess is that when you add an image via the report designer (maybe using a canvas and calling toDataURL), the data is stored in a compressed or packed format (_packAndEncryptContent). But when I add it in Node.js, it just adds the plain base64 as _content.

Questions

* Is there a way to add an image as a resource in NodeJS so that it’s stored in the “packed” format (_packAndEncryptContent)?
* Or is there a way to force Stimulsoft to use my base64 image stored in _content so that it displays correctly in the report when referenced as resource://logo2?
* Has anyone solved this issue in a Node.js environment, or is this only possible in C#/.NET?

Any pointers, code snippets, or workarounds would be greatly appreciated!

Thanks in advance for your help!
Lech Kulikowski
Posts: 7308
Joined: Tue Mar 20, 2018 5:34 am

Re: Issues Adding Images as Resources via NodeJS API

Post by Lech Kulikowski »

Hello,

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

Thank you.
#17725
Post Reply