jblotus/aws-lambda-wkhtmltopdf

Exported PDF file has error.

DE-NinhNguyen opened this issue · 5 comments

Dear Lubos,

I have tried to apply your source code to AWS Lambda.
I could execute lambda function successfully, but the the exported PDF file has error in format.
Adobe Reader can't read the file.
screenshot_2
Have you ever got this issue?
If you have any info, could you share with me?

Thanks so much for your help!

lubos commented

Can you check the size of output PDF file? Some people experienced 0-bytes output.

Hi Lubos,

I have checked the PDF file, the size is 0-bytes. I am trying to find out the way to fix this.

P/s: I am try to integrate the Japanese fonts (Noto Sans CJK fonts ) into your source code.
could you give any idea where i can put the fonts file (*.otf) in your source code?
Sorry for asking you too many question!

Thank you so much for your reply!

lubos commented

I had this issue too once and simply re-uploading the package to AWS lambda has fixed the issue for me. Haven't seen it since then.

So this is something I can't really explain. You will just need to experiment with it.

I had this issue as well. Turned out my problem was that the wkhtmltopdf file taken from the git clone was not executable yet (I hadn't caught that because my local machine had its own version of wkhtmltopdf on the path). I had to chmod the file then it worked in lambda

lubos commented

I've made some changes to this function. It will return PDF in base64 rather than uploading to S3 bucket (Lambda doesn't support binary output)

Also HTML input must be in Base64 too. This avoids certain issues with UTF8.

This means there is no config.js file and no special permissions. So people can just use this project without making any changes to the code.