[JAVA] Things to keep in mind when using Apache PDFBox® with AWS Lambda

Apache PDFBox® is a Java open source library for messing around with PDFs.

Since AWS Lambda can use the Java 8 runtime, running it on AWS Lambda is not particularly difficult, but there are a few caveats, so I will leave it in the article.

important point

As a specification when Lambda is executed, access rights such as writing are restricted for folders other than / tmp, but since it tries to update the font cache as the default operation of PDFBox, an error occurs due to the access rights at that time. Become.

To avoid this, you need to set the system property pdfbox.fontcache to / tmp.

For example, after executing a Lambda handler function and before using PDFBox

Handler function


System.setProperty("pdfbox.fontcache", "/tmp");

You can avoid it by doing.

reference

Apache PDFBox®

Recommended Posts

Things to keep in mind when using Apache PDFBox® with AWS Lambda
Things to keep in mind when using Sidekiq with Rails
Things to keep in mind when using if statements
Things to keep in mind when committing to CRuby
Things to keep in mind when adding war to dependency
Things to keep in mind when testing private methods in JUnit
Things to keep in mind when combining if statements and logical operators
N things to keep in mind when reading "Introduction to Spring" and "Introduction to Spring" in the Reiwa era
Things to keep in mind when installing Jekyll on Windows and loading themes! !! Need tzinfo !!
Things to note when using Spring AOP in Jersery resource classes
[Java Bronze] 5 problems to keep in mind
How to use Java framework with AWS Lambda! ??
[Comma (,) is strictly prohibited in the address! ] Things to keep in mind when applying for an exam at Pearson VUE
Things to check when it doesn't work with proguard
Whether to enable SSL when using JDBC with MySQL.
How to deploy Java to AWS Lambda with Serverless Framework
Things to be aware of when using devise's lockable
Things to watch out for when using Deeplearning4j Kmeans
How to set environment variables when using Payjp with Rails
Things to be aware of when writing code in Java
docker-compose.yml when you want to keep mysql running with docker
When I try to use the AWS SDK with Ruby + Lambda, `sam local` is messed up.
[For super beginners] The minimum knowledge you want to keep in mind with hashes and symbols
Japaneseize using i18n with Rails
Build AWS Lambda with Quarkus
I can't log in to MySQL from Django when using docker-compose
Install gem in Serverless Framework and AWS Lambda with Ruby environment
Things to consider when running a specified job using Spring Batch
How to run a job with docker login in AWS batch
Things to forget when intercepting a request with Android's WebView # shouldInterceptRequest
How to solve the unknown error when using slf4j in Java