aws-lambda-libreoffice
aws-lambda-libreoffice copied to clipboard
Password protected documents are not handled successfully
In our use case, password protected documents are quite common. People try to preview them, and the lambda conversion function fails because obviously the files are encrypted. I do believe that it's expected behavior for these conversions to fail, but fail in a user-friendly manner.
Currently, this case ends up in a JS error:
Cannot read property '1' of null
It's thrown by this line of code https://github.com/shelfio/aws-lambda-libreoffice/blob/ab4dde6f041498bd78c7773ae5a9103cb71153db/src/logs.ts#L2
Because output of soffice --convert-to
command outputs some error instead of converted file path
I might provide a pull request to somehow avoid this in the near future. I think the easiest solution would to find an easy way of finding out whether a file is encrypted or not, but a quick google search did not help me out. Perhaps somebody else has a better solution ?
EDIT: I noticed there has already been an issue regarding this problem, but hopefully I or somebody else will come up with a solution this time. https://github.com/shelfio/aws-lambda-libreoffice/issues/28
Hi @tadasauciunas . My ask is a little different from the one you posted but on the same subject. I want to know the parameter to pass the "password" in the soffice command so that the word document opens and converts to a pdf. Currently, all my docs without passwords work fine except for the ones with passwords.
The error I am getting is -
[INFO] 2021-11-22T18:04:11.299Z REQUESTID CompletedProcess(args=['/tmp/instdir/program/soffice.bin', '--headless', '--norestore', '--invisible', '--nodefault', '--nofirststartwizard', '--nolockcheck', '--nologo', '--convert-to', 'pdf:writer_pdf_Export', '--outdir', '/tmp/path', '/tmp/path/file.doc'], returncode=0, stdout=b'', stderr=b'Fontconfig error: Cannot load default config file\nError: source file could not be loaded\n')