
At IDRsolutions, we eat our own dog food!
We have weekly and monthly analytics reports that help us keep track of our KPIs, and we like to save a copy of these each time they are generated. These reports come from Looker Studio, however we prefer to use Basecamp as our single source of truth so ideally, the reports should be archived somewhere, then made available on Basecamp.
Up until recently, we had a manual task for somebody to login to Looker Studio, download the PDF, and upload it to Basecamp. So we did what developers do best, and automated the whole process!
Looker Studio has a scheduling system where it will email a PDF generated from the report at regular intervals. We enabled this so that we could receive the report PDF in Salesforce where we have an Apex trigger to detect it, which then allows us to use our PDF to HTML converter BuildVu, to convert and store the file.
Using techniques described in this article, we pick up the PDF as it arrives in Salesforce:
// Whenever a new file arrives on Salesforce, filter it to see if it is the weekly report PDF.
EmailMessage emailMessage = [SELECT Id, Subject, FromAddress, ParentId FROM EmailMessage WHERE Id = :contentDocumentLink.LinkedEntityId LIMIT 1];
if (emailMessage == null || !emailMessage.Subject.contains(‘Weekly Report’) || emailMessage.FromAddress != ‘looker-studio-noreply@google.com’) {
continue;
}
ContentDocument contentDocument = [SELECT Id, FileExtension FROM ContentDocument WHERE Id = :contentDocumentLink.ContentDocumentId LIMIT 1];
if (contentDocument == null || contentDocument.FileExtension.toLowerCase() != ‘pdf’) {
continue;
}
Then we send it to our internal microservice running BuildVu where the PDF is converted to HTML and a link to the conversion is posted on Basecamp:
@future(callout = true)
public static void postWeeklyReport(String pdfUrl) {
// Post to storage
HttpResponse response = Utils.executePOSTRequest(‘callout:IDRstorage/buildvu’, ‘input=download&settings={"org.jpedal.pdf2html.originalFileName":"‘ + EncodingUtil.urlEncode(name, ‘UTF-8’) + ‘"}&url=’ + EncodingUtil.urlEncode(pdfUrl, ‘UTF-8’));
String uuid = Utils.getValue(response.getBody(), ‘uuid’);
// Post to Basecamp
Utils.executePOSTRequest(‘https://3.basecampapi.com/’ + accountId + ‘/buckets/123456/message_boards/12345678/messages.json’,
‘{"subject":"Weekly Report – ‘ + currentDay + ‘ ‘ + currentMonth
+ ‘","content":"<div><a href=\\\"https://idrstorage.idrsolutions.com/view?id=’ + uuid + ‘\\\">IDRstorage</a></div>","status":"active","category_id":"12345678″}’);
}
Dogfooding the latest builds of BuildVu has surfaced multiple product enhancements that wouldn’t have emerged without firsthand use.
Download BuildVu
Download a BuildVu trial jar so you can add a clean, modern PDF to HTML converter to your document processing pipeline.
Resources
Learn more about how the BuildVu API works.
Curious to learn more about how PDF files work?
BuildVu allows you to
| View PDF files in a Web app |
| Convert PDF documents to HTML5 |
| Parse PDF documents as HTML |
What is BuildVu?
BuildVu is a commercial SDK for converting PDF files into standalone HTML or SVG.
Why use BuildVu?
BuildVu allows you to integrate PDF into your HTML workflow effortlessly and securely by producing clean HTML that is easy for developers to work with.
What licenses are available?
We have 3 licenses available:
Cloud for conversion using the shared IDRsolutions cloud server, Self hosted server option for your own cloud or on-premise servers, and Enterprise for more demanding requirements.
How to use BuildVu?
Want to learn more about BuildVu and how to use it, we have plenty of tutorials and guides to help you.