<?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[How to handle if the src given in docx Hyperlink image is not available.]]></title><description><![CDATA[<p>Hi, We are using docx report to generate the report. But when hyperlink is given to image and if the image is not available it Throws error 'Error: Error while executing docx recipe. getaddrinfo ENOTFOUND picsm.photos\n    at module.exports ...........'.<br />
Is there any other methods I can render images ? for example with base64?<br />
and if the image is not available can I show nothing?</p>
]]></description><link>https://forum.jsreport.net/topic/2574/how-to-handle-if-the-src-given-in-docx-hyperlink-image-is-not-available</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Jul 2026 15:57:33 GMT</lastBuildDate><atom:link href="https://forum.jsreport.net/topic/2574.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 22 Sep 2022 06:52:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to handle if the src given in docx Hyperlink image is not available. on Invalid Date]]></title><description><![CDATA[<p>Hi, We are using docx report to generate the report. But when hyperlink is given to image and if the image is not available it Throws error 'Error: Error while executing docx recipe. getaddrinfo ENOTFOUND picsm.photos\n    at module.exports ...........'.<br />
Is there any other methods I can render images ? for example with base64?<br />
and if the image is not available can I show nothing?</p>
]]></description><link>https://forum.jsreport.net/post/11162</link><guid isPermaLink="true">https://forum.jsreport.net/post/11162</guid><dc:creator><![CDATA[Dhurba123a]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to How to handle if the src given in docx Hyperlink image is not available. on Invalid Date]]></title><description><![CDATA[<p>hi! yes the image also accepts base64 input but in the shape of a base64 data uri, see this <a href="https://playground.jsreport.net/w/admin/UwTKeBUW" rel="nofollow">example</a> that uses base64 data uri for the image.</p>
]]></description><link>https://forum.jsreport.net/post/11166</link><guid isPermaLink="true">https://forum.jsreport.net/post/11166</guid><dc:creator><![CDATA[bjrmatos]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to How to handle if the src given in docx Hyperlink image is not available. on Invalid Date]]></title><description><![CDATA[<p>What happens when the image is not available? It's giving Error: Error while executing docx recipe. getaddrinfo ENOTFOUND image.<br />
Is there any way around  so that I can render remaining part of the report if image is not available. Please help..its urgent</p>
]]></description><link>https://forum.jsreport.net/post/11167</link><guid isPermaLink="true">https://forum.jsreport.net/post/11167</guid><dc:creator><![CDATA[Dhurba123a]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to How to handle if the src given in docx Hyperlink image is not available. on Invalid Date]]></title><description><![CDATA[<p>yes, right now it just throws an error, there is no special handling on this. perhaps we can consider implementing some kind of <code>fallbackSrc</code> when this happens, but this can also be done right now using helpers.</p>
<p>here is link that shows how to implement a custom fallback <a href="https://playground.jsreport.net/w/anon/qM203vEC" rel="nofollow">https://playground.jsreport.net/w/anon/qM203vEC</a></p>
<p>you need to update the helper call in your hyperlink to be like this</p>
<p><img src="/uploads/files/1663951061150-screenshot-2022-09-23-at-11.36.42-2x.jpeg" alt="0_1663951059839_Screenshot 2022-09-23 at 11.36.42@2x.jpg" class="img-responsive img-markdown" /></p>
<p>and in your template have this helper:</p>
<pre><code class="language-js">const jsreport = require('jsreport-proxy')
const axios = await jsreport.npm.require('axios@0.24.0')

async function docxImageWithFallback (options) {
    const src = options.hash.src

    if (src.startsWith('data:')) {
        return src
    }

    try {
        console.log('sending request...')
        const response = await axios({
            url: src,
            responseType: 'arraybuffer',
            method: 'GET'
        })

        const contentType = response.headers['content-type'] || response.headers['Content-Type']

        if (!contentType) {
        throw new Error(`Empty content-type for remote image at &quot;${src}&quot;`)
        }

        const extensionsParts = contentType.split(';')[0].split('/').filter((p) =&gt; p)

        if (extensionsParts.length === 0 || extensionsParts.length &gt; 2) {
        throw new Error(`Invalid content-type &quot;${contentType}&quot; for remote image at &quot;${src}&quot;`)
        }

        // some servers returns the image content type without the &quot;image/&quot; prefix
        imageExtension = extensionsParts.length === 1 ? extensionsParts[0] : extensionsParts[1]
        imageBuffer = Buffer.from(response.data)
        imgDataUri = `data:image/${imageExtension};base64,${imageBuffer.toString('base64')}`
    } catch (err) {
        imgDataUri = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAK8AAAAtCAIAAABXiKzxAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAgdSURBVHhe7Zj9T1NXGMeX/brsD1iWJZtZtv2wDbVoeRNqQUFaaXlTQJGIjGWmugW2xfoSDA6WaRHHL84tEzZXnNJoeNFVnVQddQhVpC6jikuj7iaGGg3l7fJ2u3PPObf3lRYEEmTnk/7Afc5zzrnP83w5L/clFYHAQdRA4CFqIPAQNRB4iBoIPEQNBB6iBgIPUQOBh6iBwEPUQOAhaiDwEDUQeIgaCDxzpoaCgoL6+vqurq7e3t47d+40Njbu2LFjxYoVuJnwIjAHatBoNC0tLQElXC6X0WjEfoQFz2zVoNVqwUqAi69En8+Xk5ODvQkLm+dXg1qtXhWfcOHiJVz2QKCnp8disezcubO8vLy9vR1bA4F7vb3xCQm42/SxOH2039NUjB9faEw2t4+GyaAcJdi2AHkeNSQb0nWH618/+XdOWx/DMDDIQENDw8qVK7EHBCgDNQG+qjmKrdPH6gb5oxxm/PgCU+b0gRz4KZfDbq8tw8aFyIzVkF2y99XmJ69cGHj5/MBpahwVu7u7WyIFxNmzZ5HDH3cfLI+KxdZFR5MXhOhtwk8yzKwYaHctflzAzEwNEQWfvtE6+NrlwSWND3WVP3j+fYyKfeDAAewhBlw0kMPQREC9q3pZbDxuWFyEUYPF5Qcrg8uCHxcwM1DD8ui49073vNU6pG74S7s2OTo6+vFjrIbCwkLsJCYpKam/vx84gO3E2DnyZuOj94t24bawSJKoN1tdFLBA/D6PvUKPGrCf3UmxOzPXQehO+71Bb1Q6j13QSrmsJtyIMFmdXj/a5lHfXNwgm6uVfRYgkwScjScYjr7C7vFxfcEeYjVz76cUj0xuwt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px7hRzrYaNW4sSXRMZXWMJxg3YBBF+ZAR0dnYmJibW1dVRFDU5OYmMT548aW5uzs7Oxn041py8kXxzIuOkEz+HQBil1QPG5G4FLDB9qFGeDTM8RvmcgkuVyWa3oTMHTBVwD7ahI+YMTpGiuVhmpoZpnSLFc0hNehubD2yQ+8+LGjTaxJSrPuPtyaRv+UNfVVUVmEpIR0cHaoqMjNTpdLm5uQaDQfFYoCk/lg5Gc01uKtmNTSEQRYnyhe9k+M5Iu2tkfgicXtrngdsFusP5XTUFoA2mKtjmcHO3eq784W+YsrRCBdGUi9uMJMg7iaJRvGFK5oAziC/FQR+5/7yoAZBXdXzdLSa7m1n346WYAtPnh4/C9+AZZQL7jp1Iyy/MKtqesfVjw5ZthvxC45Zt4G9gwb9tn2z+sizt1/asbib9NrPpl8t49NBIohR9r6FBYrhPRkrZk7jDj1V4n4Gpohyz+vokTavJ5kGDgfUImwQodQr/9Uk8B/CH/wGcu4Mvr9x/vtQQFR2db2013GYyu5nP7jI03gcw40zgyINAyi0mtYvRhfyt72I2uJmNbialrjV21fS+T0+R+dkiTxWBI4waAGDNz9t3UH/uXnnPEBIBYmxi4si9wYyOwfybQ2F/m9ufZto6taY9YDvB44YFqoFyKCy9s4KoYWrCqyHIulTd/fv3kRTATdK8Z49mtXZtcsp0fgkaDR5lWpTV4q/P+GgwlxA1TM0M1ABIS0s7derU+fPni4qKsGlegBUDu7BbsqHPBUQNUzMzNRAWN0QNBB6iBgIPUQOBh6iBwEPUQOAhaiDwEDUQeIgaCDxEDQQeogYCh0r1H3rynmXRZBCKAAAAAElFTkSuQmCC'
    }

    return docxImage.call(this, {
        ...options,
        hash: {
            ...options.hash,
            src: imgDataUri
        }
    })
}
</code></pre>
]]></description><link>https://forum.jsreport.net/post/11173</link><guid isPermaLink="true">https://forum.jsreport.net/post/11173</guid><dc:creator><![CDATA[bjrmatos]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>