cloud-function-libreoffice
v1.1.1
Published
85 MB LibreOffice to fit inside cloud function compressed with Brotli
Downloads
4
Readme
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)
: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