Using html5-to-pdf and chrome-aws-lambda packages
Clone the repository and run to setup your cloud function.
gcloud beta functions deploy generatePdf \
--trigger-http \
--runtime nodejs14 \
--memory 1024MB \
--region us-west1 \
--project {projectid}
POST /generatePdf HTTP/1.1
Content-Type: text/html
Host: {your-project}.cloudfunctions.net
Content-Length: {content-length}
{binary html content}