Automatically inject html base tag to allow relative referencing of local styles, images or scripts
"extensions": {
"base": {
"url": "${cwd}/myAssets"
},
"phantom-pdf": {
"allowLocalFilesAccess": true
}
}
The extension then injects html base tag into every valid html:
<html>
<head>
<base href="file:///jsreportFolder/myAssets" />
<script src="js/jquery.min.js"></script>
</head>
<body>
</body>
</html>
The base tag assures that relatively linked scripts, images or styles gets loaded from the specified folder without additional extra work. Only note that you may need to enable local file access in some of the pdf rendering recipe like phantom-pdf using phanton.allowLocalFilesAccess: true
option.
jsreport render
--template.engine=none
--template.recipe=phantom-pdf
--template.content=test.html
--options.base=%cd%
--out=out.pdf
POST
: http://localhost:5488/api/report
Headers
: Content-Type: application/json{ "template": { "content": "<html><head></head><body></body></html>", "recipe": "html", "engine": "handlebars" }, "options": { "base": "http://foo.com" } }