Closed Orvisky closed 8 years ago
Released in 0.4.1
I have just installed version 0.4.1 but it dont work. I set parameter, but library forces it to false, take a look:
console.log
:HtmlToPdf.prototype.execute = function (request, response) {
request.template.wkhtmltopdf = request.template.wkhtmltopdf || {};
var options = request.template.wkhtmltopdf || {};
console.log('options ', this.allowLocalFilesAccess, options);
options.allowLocalFilesAccess = this.allowLocalFilesAccess;
....
2016-01-25T10:13:08.022Z - info: Rendering anonymous template { recipe:wkhtmltopdf,engine:handlebars}
options false { allowLocalFilesAccess: true,
orientation: 'landscape',
pageSize: 'A4',
marginTop: '20',
marginRight: '20',
marginLeft: '20',
marginBottom: '10',
and result was error because of --disable-local-faile-acces.
As you see, I think this part options.allowLocalFilesAccess = this.allowLocalFilesAccess;
should be removed. If option allowLocalFilesAccess
is not set, it is disabled on line 59:
if (!options.allowLocalFilesAccess) {
params.push("--disable-local-file-access");
}
Solution. I have tested it. I commented that one line:
HtmlToPdf.prototype.execute = function (request, response) {
request.template.wkhtmltopdf = request.template.wkhtmltopdf || {};
var options = request.template.wkhtmltopdf || {};
console.log('options ', this.allowLocalFilesAccess, options);
//options.allowLocalFilesAccess = this.allowLocalFilesAccess;
2016-01-25T10:18:58.510Z - info: Rendering anonymous template { recipe:wkhtmltopdf,engine:handlebars}
options false { allowLocalFilesAccess: true,
orientation: 'landscape',
pageSize: 'A4',
marginTop: '20',
marginRight: '20',
marginLeft: '20',
marginBottom: '10',
2016-01-25T10:21:19.290Z - info: Rendering anonymous template { recipe:wkhtmltopdf,engine:handlebars}
options false { orientation: 'landscape',
pageSize: 'A4',
marginTop: '20',
marginRight: '20',
marginLeft: '20',
marginBottom: '10',
and result was error because of --disable-local-faile-acces.
Can you remove that one line ? Thank you
The wkhtmltopdf.allowLocalFilesAccess
is intended to be global configuration value. You need to set it for example in the prod.config.json
...
You seems to be passing it is as a per template option, do you need this? Isn't the global configuration affecting all templates sufficient for you?
I set it like you wrote. So, "problem" solved. Globally set to access local files. Thank you for advice.
Hi, i want to use local server images, but in your definition, you put there param
params.push("--disable-local-file-access");
.Can you make it as option ?
Thank you