jpaolin / aws-lambda-s3-wkhtmltopdf Goto Github PK
View Code? Open in Web Editor NEWThis project forked from jblotus/aws-lambda-wkhtmltopdf
Convert HTML to PDF using Webkit (QtWebKit) on AWS Lambda
This project forked from jblotus/aws-lambda-wkhtmltopdf
Convert HTML to PDF using Webkit (QtWebKit) on AWS Lambda
Hi,
I am trying to build the wkhtmltoimage in order to use the corresponding wkhtmltoimage binary that will function on Amazon Linux AMI and I am having trouble. I was hoping you could provide the one that was built when creating the wkhtmltopdf binary found the the repo!
Thanks,
Nathan
The code does not handle multi-record events. Instead it only processes the first record.
There is potential here for missed events.
const region = event.Records[0].awsRegion;
const bucket = event.Records[0].s3.bucket.name;
const key = event.Records[0].s3.object.key;
Hi,
I'm trying to get your lamda solution working and I have run into the following error.
REPORT RequestId: 21cd60a4-8986-11e7-93ce-9ff610186b10 Duration: 2159.54 ms Billed Duration: 2200 ms Memory Size: 128 MB Max Memory Used: 40 MB
11:12:33
START RequestId: 21cd60a4-8986-11e7-93ce-9ff610186b10 Version: $LATEST
START RequestId: 21cd60a4-8986-11e7-93ce-9ff610186b10 Version: $LATEST
11:12:33
2017-08-25T11:12:33.067Z 21cd60a4-8986-11e7-93ce-9ff610186b10 Invocation state = { "region": "eu-west-1", "bucket": "BUCKETNAME", "key": "htmltopdf/template.html", "input_filename": "htmltopdf/template.html", "output_filename": "htmltopdf/template.pdf" }
11:12:33
2017-08-25T11:12:33.067Z 21cd60a4-8986-11e7-93ce-9ff610186b10 Generating PDF for http://BUCKETNAME.s3-website-eu-west-1.amazonaws.com/htmltopdf/template.html
11:12:34
2017-08-25T11:12:34.504Z 21cd60a4-8986-11e7-93ce-9ff610186b10 wkhtmltopdf failed!
11:12:34
2017-08-25T11:12:34.505Z 21cd60a4-8986-11e7-93ce-9ff610186b10 {"errorMessage":"Exit with code 1 due to network error: ContentNotFoundError\n\nwkhtmltopdf exited with code 1","errorType":"Error","stackTrace":["","wkhtmltopdf exited with code 1","handleError (/var/task/node_modules/wkhtmltopdf/index.js:142:16)","ChildProcess.<anonymous> (/var/task/node_modules/wkhtmltopdf/index.js:114:7)","emitTwo (
2017-08-25T11:12:34.505Z 21cd60a4-8986-11e7-93ce-9ff610186b10
{
"errorMessage": "Exit with code 1 due to network error: ContentNotFoundError\n\nwkhtmltopdf exited with code 1",
"errorType": "Error",
"stackTrace": [
"",
"wkhtmltopdf exited with code 1",
"handleError (/var/task/node_modules/wkhtmltopdf/index.js:142:16)",
"ChildProcess.<anonymous> (/var/task/node_modules/wkhtmltopdf/index.js:114:7)",
"emitTwo (events.js:87:13)",
"ChildProcess.emit (events.js:172:7)",
"Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)"
]
}```
I'm assuming that I maybe forgot a role or something but looking at it it looks correct.
Any ideas?
Thanks
AWS support has ended.
Node.js 4.3 | December 15, 2018
When I transfert the code to nodejs12.x its doesn't work anymore saying :
libXrender.so.1: cannot open shared object file.
wkhtmltopdf was working on Node.js 8.10 but I had to transfert it to nodejs12.x because Node.js 8.10 will not be supported anymore by aws.
v0.12.4 has some issue which was fixed in upcoming version. Example table showing issue. How to update the binary.
A legitimate case could be made around fanning out S3 events using SNS, with the Lambda function as one of the subscribers. We would have to handle both S3 and SNS events as potential triggers.
Example S3 event
{
"Records":[
{
"eventVersion":"2.0",
"eventSource":"aws:s3",
"awsRegion":"us-east-1",
"eventTime":"1970-01-01T00:00:00.000Z",
"eventName":"ObjectCreated:Put",
"userIdentity":{
"principalId":"AIDAJDPLRKLG7UEXAMPLE"
},
"requestParameters":{
"sourceIPAddress":"127.0.0.1"
},
"responseElements":{
"x-amz-request-id":"C3D13FE58DE4C810",
"x-amz-id-2":"FMyUVURIY8/IgAtTv8xRjskZQpcIZ9KG4V5Wp6S7S/JRWeUWerMUE5JgHvANOjpD"
},
"s3":{
"s3SchemaVersion":"1.0",
"configurationId":"testConfigRule",
"bucket":{
"name":"mybucket",
"ownerIdentity":{
"principalId":"A3NL1KOZZKExample"
},
"arn":"arn:aws:s3:::mybucket"
},
"object":{
"key":"HappyFace.jpg",
"size":1024,
"eTag":"d41d8cd98f00b204e9800998ecf8427e",
"versionId":"096fKKXTRTtl3on89fVO.nfljtsv6qko",
"sequencer":"0055AED6DCD90281E5"
}
}
}
]
}
Example SNS event
{
"Records": [
{
"EventVersion": "1.0",
"EventSubscriptionArn": "arn:aws:sns:EXAMPLE",
"EventSource": "aws:sns",
"Sns": {
"SignatureVersion": "1",
"Timestamp": "1970-01-01T00:00:00.000Z",
"Signature": "EXAMPLE",
"SigningCertUrl": "EXAMPLE",
"MessageId": "95df01b4-ee98-5cb9-9903-4c221d41eb5e",
"Message": "Hello from SNS!",
"MessageAttributes": {
"Test": {
"Type": "String",
"Value": "TestString"
},
"TestBinary": {
"Type": "Binary",
"Value": "TestBinary"
}
},
"Type": "Notification",
"UnsubscribeUrl": "EXAMPLE",
"TopicArn": "arn:aws:sns:EXAMPLE",
"Subject": "TestInvoke"
}
}
]
}
Hi,
I tried this package and modify it a little bit (to use static url instead of s3 url).
But I get following error:
{ "errorMessage": "/bin/bash: wkhtmltopdf: command not found\n\nwkhtmltopdf exited with code 127", "errorType": "Error", "stackTrace": [ "", "wkhtmltopdf exited with code 127", "handleError (/var/task/node_modules/wkhtmltopdf/index.js:142:16)", "ChildProcess.<anonymous> (/var/task/node_modules/wkhtmltopdf/index.js:114:7)", "emitTwo (events.js:126:13)", "ChildProcess.emit (events.js:214:7)", "Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)" ] }
What this error code mean?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.