Error: conversion error: pdf2htmlEX: unrecognized option `--font-suffix'
shividhar opened this issue · 7 comments
I'm using the default code in the readme and it's giving me that error. When I don't add a preset the program logs successful but the file hasn't been created.
the same to me on windows
Same here on Mac OsX on a brew install.
I was able to fix this doing the following: (*forgive me for not doing a proper fork and pull request, I needed to get this working quickly)
Lines 3 to 9 in pdftohtml.js
function pdftohtml (path, filename, outfile, options) {
this.path = path;
this.options = options || {};
this.options.additional = [path + '/' + filename];
if (typeof outfile !== "undefined" && outfile !== null) {
this.options.additional.push(path + '/' + outfile);
}
On line 51 in pdftohtml.js
var child = shell.exec('cd ' + self.path + ' && pdf2htmlEX ' + self.options.additional.join(' '), {async:true, silent:true});
I was able to do the following implementation:
exports.resource = function(req, res) {
console.log(req.query);
var extension = path.extname(req.query.resource);
var filename = path.basename(req.query.resource, '.pdf');
var dir = path.dirname(req.query.resource);
if(extension === '.pdf'){
var converter = new pdftohtml(dir, filename + extension, filename + '.html');
converter.preset('default');
converter.success(function() {
console.log('convertion done');
res.send(fse.readFileSync(dir + '/' + filename + '.html', 'UTF-8'));
});
converter.error(function(error) {
console.log('conversion error: ' + error);
});
converter.progress(function(ret) {
console.log ((ret.current*100.0)/ret.total + ' %');
});
converter.convert();
}else{
res.send(fse.readFileSync(req.query.resource, 'UTF-8'));
}
};
I know it's fairly verbose, but just wanted to share:) Now on to cleaning up the html that pdf2htmlEX spits out 👹
Also default.js should be:
exports.load = function(pdf2htmlex) {
pdf2htmlex.add_options([
'--zoom 1.3',
'--font-format woff'
]);
return pdf2htmlex
}
@hydrotik It was fixed in 2013, the changes just haven't been pushed to NPM yet.
Awesome thanks!
My apologies for not updating it on npm in timely manner. I've just pushed v0.3.6
to npm which is tested with iojs
and node v0.12.x
@hydrotik --zoom 1.3
and --zoom 1.33
both works on MacOS so I don't see a point here, anyways presets are meant to be subclass. You can always specify your preset file and load it in your code.