Pakistan Christian TV

Breaking news and world news from Pakisthan Christian TV on Business, Sports, Culture. Video news. News from the US, Europe, Asia Pacific, Africa, Middle East, America.

How to push a bar into an encrypted PDF

How to push a bar into an encrypted PDF

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.

This time we will return to the aforementioned Internet and to the powerful operating environment Application programming, which is part of the Google Drive repository and can use modified Javascript to automate most of the company’s services to end users.

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.

Click for a larger picture
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.

Click for a larger picture
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?

Click for a larger picture
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.

See also  Billionaire Branson and his ship have successfully returned from a test flight, reportedly reaching the frontiers of space - ČT24 - Czech TV

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.

Click for a larger picture
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.

Click for a larger picture
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[0])[0];
var souborPDF = zprava.getAttachments()[0].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.