Giter VIP home page Giter VIP logo

Comments (7)

eran-or avatar eran-or commented on August 19, 2024

the same to me on windows

from pdftohtmljs.

hydrotik avatar hydrotik commented on August 19, 2024

Same here on Mac OsX on a brew install.

from pdftohtmljs.

hydrotik avatar hydrotik commented on August 19, 2024

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 👹

from pdftohtmljs.

hydrotik avatar hydrotik commented on August 19, 2024

Also default.js should be:

exports.load = function(pdf2htmlex) {
    pdf2htmlex.add_options([
        '--zoom 1.3',
        '--font-format woff'
    ]);
    return pdf2htmlex
}

from pdftohtmljs.

haydenbleasel avatar haydenbleasel commented on August 19, 2024

@hydrotik It was fixed in 2013, the changes just haven't been pushed to NPM yet.

from pdftohtmljs.

hydrotik avatar hydrotik commented on August 19, 2024

Awesome thanks!

from pdftohtmljs.

iapain avatar iapain commented on August 19, 2024

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.

from pdftohtmljs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.