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 年之前
5 年之前
5 年之前
5 年之前
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # document-convert
  2. [![Build Status](https://travis-ci.com/kalimuthu-selvaraj/document-convert.svg?branch=master)](https://travis-ci.com/kalimuthu-selvaraj/document-convert) [![Coverage Status](https://coveralls.io/repos/github/kalimuthu-selvaraj/document-convert/badge.svg?branch=master)](https://coveralls.io/github/kalimuthu-selvaraj/document-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. ## LibreOffice test
  8. libreOfficeInstallationPath --headless --convert-to pdf --outdir outputDir sourceFile(test.pdf),
  9. ## LibreOffice Installation Path
  10. Windows
  11. ```
  12. C:\\Program Files\\LibreOffice\\program\\soffice.exe (or)
  13. C:\\Program Files (x86)\\LibreOffice\\program\\soffice.exe (or)
  14. C:\\Program Files (x86)\\LIBREO~1\\program\\soffice.exe
  15. ```
  16. Ubuntu
  17. ```
  18. /usr/bin/libreoffice (or)
  19. /usr/bin/soffice
  20. ```
  21. Mac OS
  22. ```
  23. /Applications/LibreOffice.app/Contents/MacOS/soffice
  24. ```
  25. ## Imagemagic test
  26. convert -verbose -resize 1200 -density 200 test.pdf test-%d.png(%d inserts the images `scene number`)
  27. ## Usage Example
  28. ```javascript
  29. // Import convert module
  30. const document = require("./convert");
  31. const options = {
  32. libreofficeBin: "C:\\Program Files\\LibreOffice\\program\\soffice.exe",
  33. sourceFile: "C:\\convert-pdf-img\\sample.pptx", // .ppt, .pptx, .odp, .key and .pdf
  34. outputDir: "C:\\convert-pdf-img\\output",
  35. img: false,
  36. imgExt: "jpg", // Optional and default value png
  37. reSize: 800, // Optional and default Resize is 1200
  38. density: 120, // Optional and default density value is 120
  39. };
  40. // Convert document to pdf and/or image
  41. document
  42. .convert(options)
  43. .then((res) => {
  44. console.log("res", res); // Success or Error
  45. })
  46. .catch((e) => {
  47. console.log("e", e);
  48. });
  49. ```