<?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[Compile a template with local assets]]></title><description><![CDATA[<p>Hi,<br />
I need to compile a template by jsreport-core, but I cannot do that because the assets are not found.</p>
<p>This is my code:<br />
const jsreport = require('jsreport-core')()</p>
<p>jsreport.use(require('jsreport-assets')({<br />
    searchOnDiskIfNotFoundInStore: true,<br />
    allowedFiles: '<em><em>/</em>.</em>',<br />
	publicAccessEnabled: true<br />
}))</p>
<p>var fs = require('fs')</p>
<p>jsreport.init().then(() =&gt; {<br />
	return jsreport.render({<br />
		template: {<br />
			content: fs.readFileSync('main'),<br />
			helpers: fs.readFileSync('helpers.js'),<br />
			engine: 'handlebars',<br />
			recipe: 'chrome-pdf'<br />
		},<br />
		data: JSON.parse(fs.readFileSync('data.json'))<br />
	}).then((resp) =&gt; {<br />
		fs.writeFileSync('./report.pdf', resp.content)<br />
		console.log('Saved!')<br />
 	});<br />
}).catch((e) =&gt; {<br />
	console.error(e)<br />
})<br />
 <br />
The assets (for example some images) are placed in the same directory of the template &quot;main&quot;.<br />
First problem: when I try the code as above, the assets are searched in the installation directory of jsreport, but I would like in the directory where is placed the template (or the script).<br />
Second problem: if I move all the assets in the installation directory, the script fails with the error: &quot;Engine 'handlebars' not found.&quot;<br />
Actually, this error happens always when this part of code is enabled:</p>
<p>jsreport.use(require('jsreport-assets')({<br />
    searchOnDiskIfNotFoundInStore: true,<br />
    allowedFiles: '<em><em>/</em>.</em>',<br />
	publicAccessEnabled: true<br />
}))<br />
but I need it to use local assets!</p>
<p>I hope someone can figure out the problem.<br />
Thank you!<br />
Best regards</p>
]]></description><link>https://forum.jsreport.net/topic/1977/compile-a-template-with-local-assets</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Jul 2026 11:46:04 GMT</lastBuildDate><atom:link href="https://forum.jsreport.net/topic/1977.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 16 Apr 2021 15:02:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Compile a template with local assets on Invalid Date]]></title><description><![CDATA[<p>Hi,<br />
I need to compile a template by jsreport-core, but I cannot do that because the assets are not found.</p>
<p>This is my code:<br />
const jsreport = require('jsreport-core')()</p>
<p>jsreport.use(require('jsreport-assets')({<br />
    searchOnDiskIfNotFoundInStore: true,<br />
    allowedFiles: '<em><em>/</em>.</em>',<br />
	publicAccessEnabled: true<br />
}))</p>
<p>var fs = require('fs')</p>
<p>jsreport.init().then(() =&gt; {<br />
	return jsreport.render({<br />
		template: {<br />
			content: fs.readFileSync('main'),<br />
			helpers: fs.readFileSync('helpers.js'),<br />
			engine: 'handlebars',<br />
			recipe: 'chrome-pdf'<br />
		},<br />
		data: JSON.parse(fs.readFileSync('data.json'))<br />
	}).then((resp) =&gt; {<br />
		fs.writeFileSync('./report.pdf', resp.content)<br />
		console.log('Saved!')<br />
 	});<br />
}).catch((e) =&gt; {<br />
	console.error(e)<br />
})<br />
 <br />
The assets (for example some images) are placed in the same directory of the template &quot;main&quot;.<br />
First problem: when I try the code as above, the assets are searched in the installation directory of jsreport, but I would like in the directory where is placed the template (or the script).<br />
Second problem: if I move all the assets in the installation directory, the script fails with the error: &quot;Engine 'handlebars' not found.&quot;<br />
Actually, this error happens always when this part of code is enabled:</p>
<p>jsreport.use(require('jsreport-assets')({<br />
    searchOnDiskIfNotFoundInStore: true,<br />
    allowedFiles: '<em><em>/</em>.</em>',<br />
	publicAccessEnabled: true<br />
}))<br />
but I need it to use local assets!</p>
<p>I hope someone can figure out the problem.<br />
Thank you!<br />
Best regards</p>
]]></description><link>https://forum.jsreport.net/post/8715</link><guid isPermaLink="true">https://forum.jsreport.net/post/8715</guid><dc:creator><![CDATA[k3lusk]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>