5. Generate consistent output
2. Handle multiple languages
3. Compile scripts and styles
4. Abstract data by type
It’s important that any application give its users easy and useful access to their data. With web applications this requirement can pose increased difficulty. Desktop web browsers will offer to print a page of data, but the format will vary from browser to browser – and what about users on smartphones and tablets? Moreover, printed output is only part of the requirement: users also want to export data in a format that allows them to slice and dice it outside the application. For usability, the ElseApps Framework needed to handle both types of output – printing and exporting – in a consistent and effective manner.
For printing we elected to generate PDF documents instead of relying on the variable effectiveness of the user’s browser. This has the additional advantages of producing output on most mobile devices, and of providing a single file that users can store and retrieve in their own systems.
There are PHP libraries available to help with generating PDF output. We tested several and found them a patchy lot. We decided to wrap one of the more widely used libraries in our own class, a class written to render the twenty data types used in EAF’s dynamically created forms. This approach enabled us to compensate for the library’s worst inconsistencies and, of course, once we’d written this, any and every form created within the application is rendered consistently.
Having created the PDF generation class, extending it to provide output for other areas of the web application was straightforward. We also added configuration settings for the client’s logo, colours and preferred fonts, so configuring printing for a new client is a trivial step.
Users upload supporting files as part of a funding application, and we embed any type and any number of these into the PDF. Once generated, the user has a single PDF document that contains every element of the application.
We’ve called the next lesson from EAF “6. Reusable reusability“.