initial code from iText tutorial and "ntrax" post on Stackoverflow