<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Can Images stored as varbinary(max) in SQL Database be displayed?]]></title><description><![CDATA[<p>I have images stored in a MS SQL Database table as varbinary(max) and I'm trying to figure out how to display them in JSReport.  Currently I'm calling them from a script and want to do something like:</p>
<pre><code>{{#each logo}}
   &lt;img src=&quot;{{asset &quot;{{logo}}&quot; &quot;dataURI&quot;}}&quot; /&gt;
{{/each}}
</code></pre>
<p>It throws errors whichever way I've attempted to do it.</p>
<p>Any suggestions?</p>
]]></description><link>https://forum.jsreport.net/topic/2991/can-images-stored-as-varbinary-max-in-sql-database-be-displayed</link><generator>RSS for Node</generator><lastBuildDate>Fri, 09 Oct 2026 07:37:14 GMT</lastBuildDate><atom:link href="https://forum.jsreport.net/topic/2991.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 13 Nov 2023 23:06:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Can Images stored as varbinary(max) in SQL Database be displayed? on Invalid Date]]></title><description><![CDATA[<p>I have images stored in a MS SQL Database table as varbinary(max) and I'm trying to figure out how to display them in JSReport.  Currently I'm calling them from a script and want to do something like:</p>
<pre><code>{{#each logo}}
   &lt;img src=&quot;{{asset &quot;{{logo}}&quot; &quot;dataURI&quot;}}&quot; /&gt;
{{/each}}
</code></pre>
<p>It throws errors whichever way I've attempted to do it.</p>
<p>Any suggestions?</p>
]]></description><link>https://forum.jsreport.net/post/12835</link><guid isPermaLink="true">https://forum.jsreport.net/post/12835</guid><dc:creator><![CDATA[IAmAMFTRex]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Can Images stored as varbinary(max) in SQL Database be displayed? on Invalid Date]]></title><description><![CDATA[<p>You get the image the same way as the other data from the database. You just need to convert binary bytes into a base64 form, then you can do something like</p>
<pre><code>{{#each logo}}
   &lt;img src=&quot;data:image/png;base64,{{{imageBase64}}}&quot; /&gt;
{{/each}}
</code></pre>
]]></description><link>https://forum.jsreport.net/post/12836</link><guid isPermaLink="true">https://forum.jsreport.net/post/12836</guid><dc:creator><![CDATA[admin]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Can Images stored as varbinary(max) in SQL Database be displayed? on Invalid Date]]></title><description><![CDATA[<p>Thank you for the help but it's still not working - my images are store as jpg's so using:</p>
<pre><code>&lt;img src=&quot;data: image/jpg;base64,{{{logo}}}&quot; /&gt;
</code></pre>
<p>Displays:</p>
<pre><code>��PP@����t��;��Vї#8,z*���E�&quot;����O��/�[������y�$h�',Ǡ��$�I j�M�z�֡��0��6K�ʯ�
</code></pre>
<p>+plus a lot more gibberish</p>
<p>I know it's something stupid I'm not getting but....?</p>
]]></description><link>https://forum.jsreport.net/post/12838</link><guid isPermaLink="true">https://forum.jsreport.net/post/12838</guid><dc:creator><![CDATA[IAmAMFTRex]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Can Images stored as varbinary(max) in SQL Database be displayed? on Invalid Date]]></title><description><![CDATA[<p>What's inside <code>logo</code>? There should be base64 string.</p>
]]></description><link>https://forum.jsreport.net/post/12841</link><guid isPermaLink="true">https://forum.jsreport.net/post/12841</guid><dc:creator><![CDATA[admin]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Can Images stored as varbinary(max) in SQL Database be displayed? on Invalid Date]]></title><description><![CDATA[<p>I use the following SQL to store a standard JPG image inside a <code>varbinary(max)</code> field:</p>
<pre><code>INSERT INTO Logos(cid,logo)
SELECT 12484, BulkColumn  FROM  OPENROWSET(Bulk  'C:\Logos\12484.jpg', SINGLE_BLOB)  AS  BLOB
</code></pre>
<p>Then I have a script attached to my report that queries that table:</p>
<pre><code>async function beforeRender(req, res) {
    await sql.connect(config)
    const sqlReq = new sql.Request();
    const recordset = await sqlReq.query(
        `SELECT * FROM Logos WHERE cid=12484`
    )
    Object.assign(req.data, { logo: recordset });         
	const logo=req.data.logo.recordset;
	req.data.logo=logo;
	console.log(logo);
}```

It seems to grab it fine, but the result looks to be encoded and I'm not sure how to get it displayed as an image.</code></pre>
]]></description><link>https://forum.jsreport.net/post/12844</link><guid isPermaLink="true">https://forum.jsreport.net/post/12844</guid><dc:creator><![CDATA[IAmAMFTRex]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Can Images stored as varbinary(max) in SQL Database be displayed? on Invalid Date]]></title><description><![CDATA[<p>You just need to query sql and convert the buffer from the output to the base64.<br />
The nodejs lib you use likely returns nodejs <a href="https://nodejs.org/api/buffer.html" rel="nofollow">buffer</a> as the value of the binary column.<br />
So you need to convert it to the base64 string using <code>abuffer.toString('base64')</code>.<br />
In your case, the <code>req.data.logo</code> will be something like <code>aBff2515AasVsdEF</code> in the end.<br />
You can take the code also out of the jsreport and troubleshoot it in the plain nodejs.</p>
]]></description><link>https://forum.jsreport.net/post/12845</link><guid isPermaLink="true">https://forum.jsreport.net/post/12845</guid><dc:creator><![CDATA[admin]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>