You might see that 85MB number up there and think "what's the problem, exactly?" It's been pretty well-established that the maximum allowable packaging of code to upload to Lambdas from any source is 250MB. This sure seems like a lot of effort, why can't we just upload an unpacked instance of what's contained in that LibreOffice Layer ourselves? Well, at this point it's time to take a dive off a technical cliff. It uses Richard's Google's brotli compression algorithm to unpack a lo.tar.br file provided by the LibreOffice Lambda Layer into a given AWS Lambda Function's /tmp folder. Let's take a look at Shelf's description for their AWS-Lambda-ified LibreOffice:Ĩ5 MB LibreOffice to fit inside AWS Lambda compressed with brotliĪnd sure enough the code proves that out. The first step was to pick apart the code of the aforementioned JS library to figure out how the magic is happening. So we've established that I wanted to replicate the functionality of the Javascript Word-to-PDF conversion library in a Python-based AWS Lambda for valid and totally non ego-related reasons. Oh! So why not use Javascript instead of Python?īecause I felt like using Python and wanted a challenge? Forget about what I said earlier about avoiding writing code. In fact, there already exists a JS-based library that does exactly that! It turns out a popular strategy for converting word documents to pdf is to use the CLI capabilities of LibreOffice. The ask from the business was that the document format was preserved completely, so I couldn't risk an incomplete solution. I considered using Google Docs as the conversion workhorse, but I was informed by a coworker who had been on the project longer that Google Docs always dropped certain formatting elements, typically symbols like open paren. So I think we can all agree writing code to solve problems should be a last resort, so first I wondered if I could leverage a (hopefully free) service to do the heavy lifting. Clearly, I was about to have my hands full. That was until I forced VS Code to open the file raw: While I knew those files are packed with metadata for use during document editing, I figured I could just scrape the document until I found ascii characters. Among the formats expected to be supported were. The goal of my first task was to trigger a Lambda when documents are uploaded to an S3 bucket, and convert files of varying formats to. New or enhanced PowerBuilder objects - What's New ()ĬompressorObject object - Objects and Controls ()ĮxtractorObject object - Objects and Controls (appeon.I was recently put on a new assignment that makes heavy use of AWS for, among other things, serverless architecture. ArchiveFormatTAR! - tar format archive.įrom my tests usually 7zip gives the best result.ArchiveFormatGZip! - gzip format archive.Supports AES-256 encryption for password. lbl_pdf_compressed will contain the pdf compressed as 7zip.įormats in which you can compress are as follow (mentioned in documentation): If isvalid(lnv_compressor) then destroy lnv_compressor Lnv_press(lbl_pdf, lbl_pdf_compressed, ArchiveFormat7Zip!) Lnv_compressor.level = CompressionLevelMaximum! your blob should contain the pdf somehow (example using selectblob). Simple example of compression in PB 2019: blob lbl_pdf, lbl_pdf_compressed What I wanna say is that depending on the content of the pdfs you may see different grades of compression.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |