您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # file-convert
  2. [![Build Status](https://travis-ci.com/kalimuthu-selvaraj/file-convert.svg?branch=master)](https://travis-ci.com/kalimuthu-selvaraj/file-convert) [![Coverage Status](https://coveralls.io/repos/github/kalimuthu-selvaraj/file-convert/badge.svg?branch=master)](https://coveralls.io/github/kalimuthu-selvaraj/file-convert?branch=master)
  3. Converts `.ppt` `.pptx` `.odp` and `.key` file to `pdf or/and image(png, jpg, jpeg and etc..)`
  4. ## Dependencies
  5. Please install [libreoffice](https://www.libreoffice.org/), [imagemagick](https://www.imagemagick.org/script/index.php) and might required [ghostscript](https://www.ghostscript.com/) for Mac os
  6. **(Note: Please do restart your machine after installed all required software.)**
  7. ###IMPORTANT
  8. Make sure you install libreoffice to the USER you launch nodejs with and that this user HAS a home directory!
  9. try to convert a file from inside that USER to properly test!
  10. in case you install directly from libreoffice website,
  11. MAKE SURE you use the ./install script that comes inside the tar.gz inside the USER!
  12. ## LibreOffice test
  13. libreOfficeInstallationPath --headless --convert-to pdf --outdir outputDir sourceFile(test.pdf),
  14. ## LibreOffice Installation Path
  15. Windows
  16. ```
  17. C:\\Program Files\\LibreOffice\\program\\soffice.exe (or)
  18. C:\\Program Files (x86)\\LibreOffice\\program\\soffice.exe (or)
  19. C:\\Program Files (x86)\\LIBREO~1\\program\\soffice.exe
  20. ```
  21. Ubuntu
  22. ```
  23. /usr/bin/libreoffice (or)
  24. /usr/bin/soffice
  25. ```
  26. Mac OS
  27. ```
  28. /Applications/LibreOffice.app/Contents/MacOS/soffice
  29. ```
  30. ## Imagemagick test
  31. convert -verbose -resize 1200 -density 200 test.pdf test-%d.png (%d inserts the images `scene number`)
  32. ## Usage Example
  33. ```javascript
  34. // Import convert module
  35. const document = require("file-convert");
  36. const options = {
  37. libreofficeBin: "C:\\Program Files\\LibreOffice\\program\\soffice.exe",
  38. sourceFile: "C:\\convert-pdf-img\\sample.pptx", // .ppt, .pptx, .odp, .key and .pdf
  39. outputDir: "C:\\convert-pdf-img\\output",
  40. img: false,
  41. imgExt: "jpg", // Optional and default value png
  42. reSize: 800, // Optional and default Resize is 1200
  43. density: 120, // Optional and default density value is 120
  44. };
  45. // Convert document to pdf and/or image
  46. document
  47. .convert(options)
  48. .then((res) => {
  49. console.log("res", res); // Success or Error
  50. })
  51. .catch((e) => {
  52. console.log("e", e);
  53. });
  54. ```