SVG to PDF S3 Lambda converter
Lambda function that waits for SVG files uploaded to S3, converts them to PDF using rsvg-convert (librsvg and cairo) and uploads back to S3.
This example shows how to wire up S3 file conversion that runs an external processor, in this case rsvg-convert. This example project uses a Lambda Layer (
arn:aws:lambda:us-east-1:145266761615:layer:rsvg-convert:2) containing the pre-built binary version of rsvg-convert for AWS Lambda.
- create a S3 bucket for file uploads
Setting up the converter
npm installto fetch the dependencies
npm startto deploy the initial lambda version
- modify the package.json
connectscript to use your bucket name
npm run connectto configure your S3 bucket to invoke the lambda function when a new file is uploaded to the
Try it out
Once you've installed everything, send a test SVG file to your bucket using the S3 console, or the AWS CLI tools. The command lines below assume the bucket is called
test-svg-bucket, so adjust the commands for your bucket name accordingly.
aws s3 cp example.svg s3://test-svg-bucket/in/example.svg
Wait a few seconds, and then check if the
/out folder of your S3 bucket
aws s3 ls s3://test-svg-bucket/out/
Download the file with the same base name, but the
aws s3 cp s3://test-svg-bucket/out/example.pdf .