Skip to main content

Decrypt and Store PDF

This is an example to demonstrate how to decrypt and store a PDF file. To keep passwords secure, it uses a script property variable. You must manually create a script property named PDF_PASSWORD with the actual password in the Google Apps Script project settings.

👉 Edit this example in the playground.

{
"description": "The action custom.decryptAndStorePdf decrypts and stores a PDF file. NOTE Make sure to set the PDF_PASSWORD script property in the Google Apps Script project settings.",
"settings": {
"markProcessedMethod": "mark-read"
},
"global": {
"variables": [
{
"key": "pdfPassword",
"type": "property",
"value": "PDF_PASSWORD"
}
],
"thread": {
"match": {
"query": "has:attachment -in:trash -in:drafts -in:spam after:{{date.now|formatDate('yyyy-MM-dd')}} is:unread subject:\"[GmailProcessor-Test] decryptPdf\""
}
}
},
"threads": [
{
"match": {
"query": "subject:([GmailProcessor-Test] decryptPdf)"
},
"attachments": [
{
"description": "Process all attachments named 'encrypted*.pdf'",
"match": {
"name": "(?<basename>encrypted.*)\\.pdf$"
},
"actions": [
{
"name": "attachment.storeDecryptedPdf",
"args": {
"location": "/GmailProcessor-Tests/e2e/advanced/{{message.date|formatDate('yyyy-MM-dd')}}/decrypted.pdf",
"conflictStrategy": "replace",
"password": "${variables.pdfPassword}"
}
}
]
}
]
}
]
}

Source: decryptPdf.ts | Issues: #355 | PRs: #381