Laur IVAN

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

cell.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 :-)

Change the File Extension in Typescript – Using Path

Posted by in Software, Tutorial

Following from my previous post, I’ve updated the function to use only the path module. Now, the code looks like:

I’ve updated the workflow presented previously to: isolate the dir, ext and root components of the path replace the ext with the new extension return the normalized version of the composed path Now, our function accepts complete paths, not only filenames. Note: The path.normalize() function does NOT calculate the absolute path. It only changes the path separators. A little experiment: If you find this post and ad below useful,…read more

Change the File Extension in Typescript (or Javascript)

Posted by in Software, Tutorial

TL;DR: You need to get the root name (without the extension) and append the new extension. Then, it only depends on how tolerant you are. The other day I figured I needed a function to change the file extension (from a .jpg to a .nfo). Since I haven’t found a ready made function to do this, I decided to create my own (it’s also a good exercise for my neurons…). The function ended up having the following steps: Prerequisite: the function input parameters are the file name (not the full…read more