AWS Lambda script that generates PDF
- You can call the function directly (see this), or
- You can create a .json file containing the parameters and
PUT
it toHTML2PDF/New
folder in S3-bucket - The lambda script will then create the PDF buffer AND
- Move the .json file from
HTML2PDF/New
toHTML2PDF/Processed
(if you are calling the script by putting a .json file in S3) - Save the PDF buffer to a PDF file (if you have added the
saveToPath
parameter - Send message to AWS SQS Queue (if you have added the
QueueUrl
parameter - Additionally, it can also include specified data (that you may need in your code logic) in the SQS message if you add the
callbackData
parameter.
{
"html": "<!DOCTYPE html><html><head><title>Hello</title></head><body>Here comes the content!<body></html>",
"options": [
"--page-size Letter",
"--orientation Landscape",
"--margin-bottom 1",
"--margin-top 1",
"--margin-right 1",
"--margin-left 1"
],
"saveToPath": "HTML2PDF/_TMP/hello.pdf",
"QueueUrl": "https://sqs.eu-west-1.amazonaws.com/628439637519/ul-local-risul.fifo",
"callbackData": {
"any": "thing",
"more": "stuff"
}
}
Please also see this for all options you have for PDF generation!
If its not clear yet, you add your PDF options to the options
parameter above!
If you do not know what AWS SQS is, please take a look here.
Your business logic may require that the app should be notified when the lambda script is done. In those cases, you have to add the QueueUrl
parameter when you are developing. For the UniteLiving.com app in dev/test/prod, this will be done automatically using settings (in other words, you do not need enter QueueUrl
parameter.
For localhost, since we have to make sure that the correct developer instace gets the message, you have to add the QueueUrl
parameter.
Here are the available SQS queuee URLs for localhosts:
- https://sqs.eu-west-1.amazonaws.com/628439637519/ul-local-hasibul.fifo
- https://sqs.eu-west-1.amazonaws.com/628439637519/ul-local-masum.fifo
- https://sqs.eu-west-1.amazonaws.com/628439637519/ul-local-pappu.fifo
- https://sqs.eu-west-1.amazonaws.com/628439637519/ul-local-rashadul.fifo
- https://sqs.eu-west-1.amazonaws.com/628439637519/ul-local-risul.fifo
- https://sqs.eu-west-1.amazonaws.com/628439637519/ul-local-samiul.fifo
- https://sqs.eu-west-1.amazonaws.com/628439637519/ul-local-shahjalal.fifo
- https://sqs.eu-west-1.amazonaws.com/628439637519/ul-local-shakti.fifo
- https://sqs.eu-west-1.amazonaws.com/628439637519/ul-local-touhid.fifo