您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
kalimuthu-selvaraj ab23484333
Merge pull request #6 from kalimuthu-selvaraj/dependabot/npm_and_yarn/glob-parent-5.1.2
4 年前
test Removed test case for avoid build issue travis. 4 年前
.gitignore Updated windows path to linux. 5 年前
.travis.yml changed to arrow fn and updated travis config. 4 年前
README.md Updated .readme and test case. 4 年前
index.js changed to arrow fn and updated travis config. 4 年前
package-lock.json Bump glob-parent from 5.1.1 to 5.1.2 4 年前
package.json updated package.json. 4 年前

README.md

file-convert

Build Status Coverage Status

(new feature) disableExtensionCheck is true then converts any file(supported by libre office) to pdf or/and image(any format)

disableExtensionCheck is false then converts only .ppt .pptx .odp and .key file to pdf or/and image(png, jpg, jpeg and etc..)

Dependencies

Please install libreoffice, imagemagick and might required ghostscript for Mac os (Note: Please do restart your machine after installed all required software.)

IMPORTANT

Make sure you install libreoffice to the USER you launch nodejs with and that this user HAS a home directory!
try to convert a file from inside that USER to properly test!
in case you install directly from libreoffice website,
MAKE SURE you use the ./install script that comes inside the tar.gz inside the USER!

LibreOffice test

libreOfficeInstallationPath --headless --convert-to pdf --outdir outputDir sourceFile(test.pdf),

LibreOffice Installation Path

Windows

C:\\Program Files\\LibreOffice\\program\\soffice.exe (or)
C:\\Program Files (x86)\\LibreOffice\\program\\soffice.exe (or)
C:\\Program Files (x86)\\LIBREO~1\\program\\soffice.exe

Ubuntu

/usr/bin/libreoffice (or)
/usr/bin/soffice

Mac OS

/Applications/LibreOffice.app/Contents/MacOS/soffice

Imagemagick test

convert -verbose -resize 1200 -density 200 test.pdf test-%d.png (%d inserts the images scene number)

Usage Example

// Import convert module
const document = require("file-convert");

const options = {
  libreofficeBin: "C:\\Program Files\\LibreOffice\\program\\soffice.exe",
  sourceFile: "C:\\convert-pdf-img\\sample.pptx", // .ppt, .pptx, .odp, .key and .pdf
  outputDir: "C:\\convert-pdf-img\\output",
  img: false,
  imgExt: "jpg", // Optional and default value png
  reSize: 800, //  Optional and default Resize is 1200
  density: 120, //  Optional and default density value is 120
  disableExtensionCheck: true, // convert any files to pdf or/and image
};

// Convert document to pdf and/or image
document
  .convert(options)
  .then((res) => {
    console.log("res", res); // Success or Error
  })
  .catch((e) => {
    console.log("e", e);
  });