{"id":13393128,"url":"https://github.com/shelfio/aws-lambda-libreoffice","last_synced_at":"2025-06-10T08:09:02.039Z","repository":{"id":32446116,"uuid":"134165000","full_name":"shelfio/aws-lambda-libreoffice","owner":"shelfio","description":"Utility to work with Docker version of LibreOffice in Lambda","archived":false,"fork":false,"pushed_at":"2025-05-31T00:31:02.000Z","size":181583,"stargazers_count":237,"open_issues_count":27,"forks_count":48,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-06-03T05:45:31.015Z","etag":null,"topics":["aws-lambda","libreoffice","node-module","nodejs","npm-package","pdf-converter","pdf-generation","serverless"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shelfio.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-05-20T15:58:48.000Z","updated_at":"2025-04-28T19:01:30.000Z","dependencies_parsed_at":"2023-12-21T02:37:46.527Z","dependency_job_id":"24115eb2-eaec-4e77-aaa5-228f081f58da","html_url":"https://github.com/shelfio/aws-lambda-libreoffice","commit_stats":{"total_commits":667,"total_committers":14,"mean_commits":"47.642857142857146","dds":0.4302848575712144,"last_synced_commit":"4dd3233fce78f91499f30793298766c54e5b617f"},"previous_names":["vladgolubev/aws-lambda-libreoffice"],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shelfio%2Faws-lambda-libreoffice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shelfio%2Faws-lambda-libreoffice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shelfio%2Faws-lambda-libreoffice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shelfio%2Faws-lambda-libreoffice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shelfio","download_url":"https://codeload.github.com/shelfio/aws-lambda-libreoffice/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shelfio%2Faws-lambda-libreoffice/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259033839,"owners_count":22795772,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-lambda","libreoffice","node-module","nodejs","npm-package","pdf-converter","pdf-generation","serverless"],"created_at":"2024-07-30T17:00:43.769Z","updated_at":"2025-06-10T08:09:02.012Z","avatar_url":"https://github.com/shelfio.png","language":"TypeScript","funding_links":[],"categories":["JavaScript","AWS Lambda Functions"],"sub_categories":[],"readme":"# aws-lambda-libreoffice ![](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)\n\n\u003e Utility to work with Docker version of LibreOffice in Lambda\n\n## Install\n\n```\n$ yarn add @shelf/aws-lambda-libreoffice\n```\n\n## Features\n\n- Includes CJK and X11 fonts bundled in the [base Docker image](https://github.com/shelfio/libreoffice-lambda-base-image)!\n- Relies on the latest LibreOffice 7.4 version which is not stripped down from features as a previous layer-based version of this package\n- Requires node.js 16x runtime (x86_64)\n\n## Requirements\n\n### Lambda Docker Image\n\nFirst, you need to create a Docker image for your Lambda function.\nSee the example at [libreoffice-lambda-base-image](https://github.com/shelfio/libreoffice-lambda-base-image) repo.\n\nExample:\n\n```Dockerfile\nFROM public.ecr.aws/shelf/lambda-libreoffice-base:7.6-node18-x86_64\n\nCOPY ./ ${LAMBDA_TASK_ROOT}/\n\nRUN yarn install\n\nCMD [ \"handler.handler\" ]\n```\n\n### Lambda Configuration\n\n- At least 3008 MB of RAM is recommended\n- At least 45 seconds of Lambda timeout is necessary\n- For larger files support, you can [extend Lambda's /tmp space](https://aws.amazon.com/blogs/aws/aws-lambda-now-supports-up-to-10-gb-ephemeral-storage/) using the `ephemeral-storage` parameter\n- Set environment variable `HOME` to `/tmp`\n\n## Usage (For version 4.x; based on a Lambda Docker Image)\n\nGiven you have packaged your Lambda function as a Docker image, you can now use this package:\n\n```javascript\nconst {convertTo, canBeConvertedToPDF} = require('@shelf/aws-lambda-libreoffice');\n\nmodule.exports.handler = async () =\u003e {\n  // assuming there is a document.docx file inside /tmp dir\n  // original file will be deleted afterwards\n\n  // it is optional to invoke this function, you can skip it if you're sure about file format\n  if (!canBeConvertedToPDF('document.docx')) {\n    return false;\n  }\n\n  return convertTo('document.docx', 'pdf'); // returns /tmp/document.pdf\n};\n```\n\n## Usage (For version 3.x; based on a Lambda Layer)\n\nThis version requires Node 12.x or higher.\n\n**NOTE:** Since version 2.0.0 npm package no longer ships the 85 MB LibreOffice\nbut relies upon [libreoffice-lambda-layer](https://github.com/shelfio/libreoffice-lambda-layer) instead.\nFollow the instructions on how to add a lambda layer in [that repo](https://github.com/shelfio/libreoffice-lambda-layer).\n\n```js\nconst {convertTo, canBeConvertedToPDF} = require('@shelf/aws-lambda-libreoffice');\n\nmodule.exports.handler = async () =\u003e {\n  // assuming there is a document.docx file inside /tmp dir\n  // original file will be deleted afterwards\n\n  if (!canBeConvertedToPDF('document.docx')) {\n    return false;\n  }\n\n  return convertTo('document.docx', 'pdf'); // returns /tmp/document.pdf\n};\n```\n\nOr if you want more control:\n\n```js\nconst {unpack, defaultArgs} = require('@shelf/aws-lambda-libreoffice');\n\nawait unpack(); // default path /tmp/instdir/program/soffice.bin\n\nexecSync(\n  `/tmp/instdir/program/soffice.bin ${defaultArgs.join(\n    ' '\n  )} --convert-to pdf file.docx --outdir /tmp`\n);\n```\n\n## Troubleshooting\n\n- Please allocate at least **3008 MB** of RAM for your Lambda function.\n- If some file fails to be converted to PDF, try converting it to PDF on your computer first. This might be an issue with LibreOffice itself\n  - If you want to include some fonts/plugins to the libreoffice, contribute to the [libreoffice-lambda-base-image](https://github.com/shelfio/libreoffice-lambda-base-image) instead\n\n## See Also\n\n- [libreoffice-lambda-base-image](https://github.com/shelfio/libreoffice-lambda-base-image) - a base Docker image for you Lambdas\n- [libreoffice-lambda-layer](https://github.com/shelfio/libreoffice-lambda-layer) - deprecated, not updated anymore, used the Docker image above\n- [serverless-libreoffice](https://github.com/vladgolubev/serverless-libreoffice) - original implementation\n- [aws-lambda-tesseract](https://github.com/shelfio/aws-lambda-tesseract)\n- [aws-lambda-brotli-unpacker](https://github.com/shelfio/aws-lambda-brotli-unpacker)\n- [chrome-aws-lambda](https://github.com/alixaxel/chrome-aws-lambda)\n\n## Test\n\nBeside unit tests that could be run via `yarn test`, there are integration tests.\n\nSmoke test that it works:\n\n```sh\ncd test\n./test.sh\n\n# copy converted PDF file from container to the host to see if it's ok\nexport CID=$(cat ./cid)\ndocker cp $CID:/tmp/test.pdf ./test.pdf\n```\n\n## Publish\n\n```sh\n$ git checkout master\n$ yarn version\n$ yarn publish\n$ git push origin master --tags\n```\n\n## License\n\nMIT © [Shelf](https://shelf.io)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshelfio%2Faws-lambda-libreoffice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshelfio%2Faws-lambda-libreoffice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshelfio%2Faws-lambda-libreoffice/lists"}