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.
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.
Recommended Posts