I was able to remedy this by installing in an alternative way: sudo apt-get remove - purge wkhtmltopdf wget sudo dpkg -i wkhtmltox_0.12.6–1.bionic_b rm wkhtmltox_0.12.6–1.bionic_b The issues came when I actually pushed up code using this library to a staging environment and I noticed the PDFs were no longer generating. On initial inspection, I wasn’t experiencing the problems they mentioned ( at least in my local environment). ![]() When I first installed wkhtmltopdf, I didn’t heed the warning and just ran the following: sudo apt-get install wkhtmltopdf To use this options you should install static binary from wkhtmltopdf site” Version in debian/ubuntu repos have reduced functionality (because it compiled without the wkhtmltopdf QT patches), such as adding outlines, headers, footers, TOC etc. At the top of the installation instructions, you can see the following warning: When I was first using this library, I was also using pdfkit to drive this interaction. For continued instruction, you can skip to the next section. Our dependencies, specifically the wkhtmltopdf binary, can be handled well through AWS Lambda layers - This helps to avoid dealing with different Linux distributions or multiple installation locationsīelow is an explanation of why handling the dependencies through layers will avoid issues.It allows us to offload processing away from the server - This is more of a general benefit, we won’t actually be calling this function from a running server - These calls will also be scaled automatically.Lambda has a ton of use cases and is something I have personally used many times and am a big fan of.įor our goal, AWS Lambda is a powerful tool for the following reasons This article will use us-east-2 for the AWS region, changing this shouldn’t effect functionality, just the links within the article.Ī better way to do this is through AWS Serverless Application Model (SAM), but this is more tailored for those looking for the basic setup through the AWS Management Console.ĪWS Lambda provides serverless computing functions where you don’t need to manage any servers or containers, you can simply call your function synchronously or asynchronously, and it will be executed and scaled automatically. The event payload will contain all valid values (S3 bucket name, file key, wkhtmltopdf options, etc.).It may be best to only accept S3 file keys instead of HTML strings, but this is simply to show our functions possibilities or be used as an internal tool. Due to the way our function is called, it’s very important that you check validity of this HTML prior to calling this function if you ever use something similar in production. The HTML string or file will be valid and will include the necessary tags (, ,, ).images, -enable-external-links, etc.)įunctionality for the following options: - orientation - title - margin-bottom - margin-left - margin-right - margin-top Assumptions Accept a small set of options for the wkhtmltopdf command - A full man page can be found here - Most of the ones we’d want anyways are the default (i.e.Return a file key for the generated PDF.Allow passing either an S3 file key or an HTML string.This article assumes access to an AWS account (free-tier is acceptable) and basic knowledge of AWS Lambda/S3 and Python. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |