Employee achievement | Tejpal Borkar

Employee achievement | Tejpal Borkar

HTML to PDF

Sometimes what looks like a simple problem to solve, may bring us to an unexpected point and force us to think if to go with the old way or search for a new one.
When I came across a requirement to send the existing reports on the product dashboard as PDF attachments, I realized how true it is. A Simple feature requirement that resulted in changes that call for design and architectural skills.

The main issue was to convert the HTML pages to PDF format. We had done this before, so it seemed easy at first using traditional methods. But soon, we realized that they were not enough to get the required precise results. Now we had two options – do it the old way and produce an inefficient result, or to search for a new way to do it better.

I knew the former could not be an option, so started focusing on finding a new approach. I found a way to generate a pdf report from the react libraries using a browser application. Identification of that library was a great start. However, it was required was to generate the reports in the backend. It was not possible to use a solution that requires user interaction. I knew I can launch a browser from NodeJS in a separate session. Wow, it worked like a charm.

Once the core problem of conversion to PDF was resolved, the rest was easy. We implemented separate APIs in the backend to gather the data. REST services with Spring-boot, Java, and Microservices were some easy work.

The product has a scheduler built it. Using the scheduler it was possible to configure the frequency of the reports such as DAILY, MONTHLY, or WEEKLY, or it could also trigger a new report based on a threshold anytime.

Sometimes it can be tough to take on a road never taken before as it may be more time taking or risky. But when we carefully evaluate the benefits, the rewards might be much greater than just following the old ways. 
 
For me at least, when it comes to exploring a new technology or a new approach to solve a problem, to do or not to do, is not a question.
What about you?

Share this post