It’s Sunday and with it another continuation of our series on home programming for personal computers, servers, and small electronics for the Internet of Things.
PDF encrypted payroll strips
At our publishing house, we use Workspace subscriptions and work on Gmail. This is why the digital copy of payroll in the form of an encrypted PDF document also goes to the same Gmail every month.
Greetings from the payroll accountant in the form of an encrypted payment receipt
In previous works, we showed how to find such a message in Apps Script, extract a PDF attachment from it and then save it for archiving purposes, for example, the Payslips directory in the Drive repository. Payment confirmation is sent at the beginning of each month, so in the launch scheme it will be enough to set our archiving program to start, for example, on the 10th of each month.
But no, it requires a password for me 😲
ConvertAPI can convert documents
Well the Apps Script will archive my salary automatically, but I won’t be able to open it without a password, which is annoying because I’ll never remember it. What if the same attachments are archived in PDF for me, but some intermediate articles will decrypt them in a readable form?
Converts documents between formats, encoding, decoding…
That’s exactly what a great service would do for me in today’s example API conversion. As the name suggests, it is a universal converter application interface that can handle the conversion of all commonly used office document formats.
1500 seconds for free
Of course, ConvertAPI is not a charity, but a commercial service like any other, So the operator charges the timewhich spends its servers converting. But be careful, don’t disgust our article just yet, Each new user gets 1,500 seconds to try at first.
Don’t worry, a simple conversion will only burn units of seconds
Is it a lot or a little? It depends on the method of use. Such credit would suffice for us perhaps for several decades. Let’s try it step by step.
Looking for a salary
First, in the Apps Script, we look for the last message in Gmail that contains a payment receipt from your employer. Regular readers of our series have been able to do this for a long time, because we have been looking for various invoices and other attachments in the same way. Still, let’s do it again.
Find Payment Coupons in Gmail
The payment email address is always the “payroll bar” and must have an attachment, so I can find all the matching messages using the magic formula:
subject:"Výplatní páska" has:attachment
Snippet of code in Apps Script that finds in chronological order the smallest matching email and pulls the requested attachment from it as a global data container of type Viscous liquid, it will look like this:
var vlakna = GmailApp.search("subject:"Výplatní páska" has:attachment", 0, 1); var zprava = GmailApp.getMessagesForThread(vlakna); var souborPDF = zprava.getAttachments().copyBlob();
Decrypt a PDF file
So we must have our blob and now we are finally going to include ConvertAPI in the game. So that each of you can test your skills in advance, the service offers live show – Query editor for a specific API, while in addition to the HTTPS POST URL query there are also libraries for all kinds of languages from Python to PHP.
Continuation of the article belongs to premium content
Get unlimited access and Live without ads NS 41 CZK monthly
“Proud twitter enthusiast. Introvert. Hardcore alcohol junkie. Lifelong food specialist. Internet guru.”