cloud-function-libreoffice

1.1.1 • Public • Published

aws-lambda-libreoffice

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)

ℹ️ 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

Readme

Keywords

none

Package Sidebar

Install

npm i cloud-function-libreoffice

Weekly Downloads

0

Version

1.1.1

License

MIT

Unpacked Size

85.4 MB

Total Files

9

Last publish

Collaborators

  • draxiu98