No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is even with tonydemark:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
node_modules
.gitignore
README.md
index.js
wkhtmltoimage
wkhtmltopdf

README.md

aws-lambda-wkhtmltopdf

Convert HTML to images using Webkit (QtWebKit) on AWS Lambda

Creating function under your AWS account

  1. Log into your AWS account
  2. Under Lambda, click Create a Lambda function button
  3. When being asked to select blueprint, do not select any and click Skip button instead
  4. Do not configure any triggers and simply click Next button
  5. Enter name of your function (e.g. "html-to-image"), then select runtime Node.js 4.3
  6. In Code entry type change Edit code inline to Upload a .ZIP file
  7. Click Upload button to upload this project as zip archive.
  8. Select lambda_basic_execution role (this function doesn't need access to any part of your AWS account)
  9. Increase timeout from 3 seconds to 10 seconds or more.
  10. Click Next button
  11. Review your configuration and click Create function button

Testing function

Click Actions button, then click Configure test event and paste following json input:

{
    "html_base64" : "PGJvZHk+SGVsbG8gd29ybGQ8L2JvZHk+",
	"options":
	{
		"format": "jpg"
	}
}

html_base64 parameter represents encoded <body>Hello world</body>

Then click Save and test button. If your function is working correctly, you should receive following output:

{
  "image_base64": "/9j/4AAQSkZJRgABAQEASwBLAAD/2wBDAAIBAQIBAQICAgICAgICAwUDAwMDAwYEBAMFBwYHBwcGBwcICQsJCAgKCAcHCg0KCgsMDAwMBwkODw0MDgsMDAz/2wBDAQICAgMDAwYDAwYMCAcIDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAz/wAARCAAlBAADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc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QAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQB//Z"
}

The function will respond with a JPG encoded in Base64

Options

There are many options available to wkhtmltoimage. All of the command line options are supported as documented on the page linked to above. The options are camelCased instead-of-dashed as in the command line tool. Note that options that do not have values, must be specified as a boolean, e.g. debugJavascript: true

{
    "html_base64" : "PGJvZHk+SGVsbG8gd29ybGQ8L2JvZHk+",
	"options":
	{
		"format": "jpg"
	}
}