Styling HTML to PDF with iText 2.1.7

Posted by in Software, Tutorial

There are various solutions for producing PDFs from a HTML file, some with excellent results (e.g. ones based on the chrome renderer). Unfortunately, they usually mean adding more dependencies to an existing system. To keep things in check, we’ve chosen to use iText to generate PDFs. Following the previous post, we need to enhance the generated PDF with some styles. Now, the older versions of iText can’t use CSS directly, so we’ll need to produce the styles by hand. iText has a StyleSheet object which can load tag styles via…read more

HTML to PDF with iText 2.1.7

Posted by in Software, Tutorial

Sometimes you need to use an older version of a product die to e.g. licensing changes. It’s my case with iText. While the new version looks fantastic, their changes (and removal of e.g. RTF output) are deal breakers for the feature set we need to maintain. Therefore, 2.1.7 is the most recent version we can use. Heh. In maven, this would be:

The string resulted from the previous article can be printed out fairly easily. First, we create a document and a writer:

We write the document:

read more

Load Templates with Pebble

Posted by in Software, Tutorial

Pebble is a templating engine. It looks particularly familiar to me because I have been using Django. You have access to blocks, include/import features, loops etc. This post is a simple exercise in loading some templates. Prerequisites I’ve been using Eclipse IDE, but you can use whatever you prefer. I’ve created a maven project and added pebble dependency:

The templates I’ve created 3 templates in the resources folder of the project: index.html


Note how the {{item}} parameter is taken from the loop in *index.html. inner.html

read more

Display a Function’s Errors in Oracle

Posted by in Software, Tutorial

TL;DR: Use the power of DBMS_OUTPUT.PUT_LINE, Luke! I’ve built a function along the lines of:

When using the function, I got some 0 results and I wanted to know why. The solution I got was using DBMS_OUTPUT.PUT_LINE:

Now, all you have to do is enable DBMS_OUTPUT in your environment and you’ll see the exceptions. NOTE: This is useful while building and tuning the function. IMHO one should disable the PUT_LINE statements in production. HTH, A little experiment: If you find this post and ad below useful, please check…read more

Call an Oracle Function from Spring with CallableStatement

Posted by in Software, Tutorial

Following the previous post, I wondered if there’s a more elegant way to call a function. It turns out there is and it’s based on CallableStatement:

The CallableStatementCreator sets up the statement and the CallableStatementCallback executes the statement and returns the value up to the execute() call. Having a function:

We can build a query string like:

The CallableStatementCreator instance is then:

This states the first parameter is a result, the second and 3rd parameter are function parameters. NOTE: Be careful because you can specify indices…read more

Call an Oracle Function from Spring

Posted by in Software, Tutorial

The easiest way to call a function from Spring is using SELECT. For example, having a function HAS_PANEL_FLAG_OK with two parameters and returning an integer, the function call looks like:

This will return all flags for the panels matching the condition. Java Call The query string can be something like:

and the actual query will be:

The problem I’ve encountered is the ability to specify an argument which is not part of the query. Something like this:

I’ll investigate this later… HTH, A little experiment: If…read more

Easy Volumio Plugin Development

Posted by in Software, Tutorial, Uncategorized

The past few days I’ve been struggling with building a volume controller plugin for volumio. My initial routine would be something like: edit the source code on a PC zip the code and some node_modules bundled from another plugin load the plugin in volumio This presents several issues: Slow deployment cycle (even if partially automated) Unable to restart volumio without rebooting New way I’ve been looking for more info and I’ve devised a new process: Create the plugin on the raspberry pi You need to download all the prerequisites (e.g….read more

Enable SSH on Boot on Raspberry Pi

Posted by in Software

Enabling SSH on boot is as simple as placing an empty file named ssh in /boot. This works on Raspbian (and Volumio!) HTH, A little experiment: If you find this post and ad below useful, please check the ad out :-)

SoundMachine Build Log 02

Posted by in Hardware, Tutorial

I’ve decided to put in a knob to control the volume directly on the box itself. It will be controlled by volumio itself via a plugin, much like the GPIO Buttons plugin. Since this is really a development kit approach, the hardware consists of: A KY-040 rotary encoder and A screw-based prototype board Both are relatively easy and cheap to find and buy. Rotary encoder The encoder is straight-forward cheap version, with a push button too, just in case. It’s even mounted on a PCB and has pins too, so…read more

Build Log 01

Posted by in Hardware, Tutorial

A while ago I’ve decided to try my hand at replacing my Sonos system with a DIY version of a sound system. I have two reasons to do this: I think it’s going to be fun and I have a bunch of FLAC files at odd resolutions which are not really playable by the Sonos system. After giving it some thought, I’ve settled on the following configuration: A Raspberry Pi A sound card for the Raspberry Pi. For starters I’ll be going with a Chinese clone An amplifier A couple…read more