1.1.1 • Published 3 years ago

cloud-function-libreoffice v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

aws-lambda-libreoffice npm.io

85 MB LibreOffice to fit inside AWS Lambda compressed with Brotli

Inspired by chrome-aws-lambda

✨ Also works in Google Cloud Functions as long as you select Node.js 8 runtime (thanks to ncruces for the info)

:information_source: Compiled LibreOffice version: 6.1.0.0.alpha0

Install

$ yarn add @shelf/aws-lambda-libreoffice

Usage

const {convertFileToPDF} = require('@shelf/aws-lambda-libreoffice');

module.exports.handler = async () => {
  // assuming there is a document.docx file inside /tmp dir
  // original file will be deleted afterwards

  return convertFileToPDF('/tmp/document.docx'); // will create /tmp/document.pdf
};

Or if you want more control:

const {getExecutablePath, defaultArgs} = require('@shelf/aws-lambda-libreoffice');

const loBinary = await getExecutablePath(); // /tmp/instdir/program/soffice

execSync(`${loBinary} ${defaultArgs.join(' ')} --convert-to pdf file.docx --outdir /tmp`);

See Also

Test

Smoke test that it works: yarn build && docker run --rm -v "$PWD":/var/task lambci/lambda:nodejs8.10 lambda.test.handler

License

MIT © Shelf