You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
4 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. (new feature) `disableExtensionCheck` is `true` then converts any file(supported by libre office) to `pdf or/and image(any format)`
  4. `disableExtensionCheck` is `false` then converts only `.ppt` `.pptx` `.odp` and `.key` file to `pdf or/and image(png, jpg, jpeg and etc..)`
  5. ## Dependencies
  6. 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
  7. **(Note: Please do restart your machine after installed all required software.)**
  8. ###IMPORTANT
  9. Make sure you install libreoffice to the USER you launch nodejs with and that this user HAS a home directory!
  10. try to convert a file from inside that USER to properly test!
  11. in case you install directly from libreoffice website,
  12. MAKE SURE you use the ./install script that comes inside the tar.gz inside the USER!
  13. ## LibreOffice test
  14. libreOfficeInstallationPath --headless --convert-to pdf --outdir outputDir sourceFile(test.pdf),
  15. ## LibreOffice Installation Path
  16. Windows
  17. ```
  18. C:\\Program Files\\LibreOffice\\program\\soffice.exe (or)
  19. C:\\Program Files (x86)\\LibreOffice\\program\\soffice.exe (or)
  20. C:\\Program Files (x86)\\LIBREO~1\\program\\soffice.exe
  21. ```
  22. Ubuntu
  23. ```
  24. /usr/bin/libreoffice (or)
  25. /usr/bin/soffice
  26. ```
  27. Mac OS
  28. ```
  29. /Applications/LibreOffice.app/Contents/MacOS/soffice
  30. ```
  31. ## Imagemagick test
  32. convert -verbose -resize 1200 -density 200 test.pdf test-%d.png (%d inserts the images `scene number`)
  33. ## Usage Example
  34. ```javascript
  35. // Import convert module
  36. const document = require("file-convert");
  37. const options = {
  38. libreofficeBin: "C:\\Program Files\\LibreOffice\\program\\soffice.exe",
  39. sourceFile: "C:\\convert-pdf-img\\sample.pptx", // .ppt, .pptx, .odp, .key and .pdf
  40. outputDir: "C:\\convert-pdf-img\\output",
  41. img: false,
  42. imgExt: "jpg", // Optional and default value png
  43. reSize: 800, // Optional and default Resize is 1200
  44. density: 120, // Optional and default density value is 120
  45. disableExtensionCheck: true, // convert any files to pdf or/and image
  46. };
  47. // Convert document to pdf and/or image
  48. document
  49. .convert(options)
  50. .then((res) => {
  51. console.log("res", res); // Success or Error
  52. })
  53. .catch((e) => {
  54. console.log("e", e);
  55. });
  56. ```