Skip to content

Commit

Permalink
pageConfig passed
Browse files Browse the repository at this point in the history
  • Loading branch information
gauravds committed Dec 27, 2023
1 parent 546304e commit 9a5735c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async function getBrowser() {

const requiredAttributes = ['htmlContent', 's3Path', 's3FilePublic', 's3Region', 's3Bucket', 's3KeyId', 's3SecretKey']
// return the uploaded URL
async function createPdfAndUploadToS3({ htmlContent, s3Path, s3FilePublic, s3Region, s3Bucket, s3KeyId, s3SecretKey }) {
async function createPdfAndUploadToS3({ htmlContent, s3Path, s3FilePublic, s3Region, s3Bucket, s3KeyId, s3SecretKey }, pageConfig = {}) {
const browser = await getBrowser()
const page = await browser.newPage()
const content = htmlContent
Expand All @@ -35,6 +35,7 @@ async function createPdfAndUploadToS3({ htmlContent, s3Path, s3FilePublic, s3Reg
bottom: 30,
left: 0,
},
...pageConfig,
})
await browser.close()

Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async function main(event) {
return generateResponse(400, { message: `Missing attribute, It should contain the following attributes. ${requiredAttributes}` })
}

const url = await createPdfAndUploadToS3(reqBody)
const url = await createPdfAndUploadToS3(reqBody, reqBody.pageConfig)
const res = await generateResponse(200, { url })
return res
}
Expand Down

0 comments on commit 9a5735c

Please sign in to comment.