index.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * Created by fy on 15-9-4.
  3. */
  4. 'use strict';
  5. /**
  6. * PDF转换HTML
  7. * @param pdf
  8. * @param dest
  9. * @param html
  10. * @param success
  11. * @param error
  12. * @param progress
  13. * @example pdf2html('scala-gailan.pdf', "test", "scala-gailan.html");
  14. */
  15. function pdf2html(pdf, dest, html, success, error, progress) {
  16. var converter = new pdftohtml(pdf, html);
  17. converter.add_options([
  18. '--process-outline 0',
  19. '--embed-outline 0',
  20. '--fit-width 360',
  21. '--split-pages 1',
  22. '--dest-dir ' + dest
  23. ]);
  24. // converter.preset('default');
  25. if (success == undefined || typeof success != 'function')success = function () {
  26. console.log("convertion done");
  27. };
  28. converter.success(success);
  29. if (error == undefined || typeof error != 'function')error = function (e) {
  30. console.log("conversion error: " + e);
  31. };
  32. converter.error(error);
  33. if (progress == undefined || typeof progress != 'function')progress = function (ret) {
  34. console.log((ret.current * 100.0) / ret.total + " %");
  35. };
  36. converter.progress(progress);
  37. converter.convert();
  38. }
  39. module.exports.pdf2html = pdf2html;