4

I am writing a desktop application in Java, which has all of the Airband radio frequencies for the UK in it.

I would like to make this frequency database downloadable so people can print it. Would it be best to create the database in XML or use PDF for the download to print? Or perhaps there is another, better option?

Matt Ellen
  • 3,368
  • 4
  • 30
  • 37
NeonLinux
  • 308
  • 1
  • 8

5 Answers5

11

First thing, the storage format is almost never the same as the print format (unless there's a very good reason).

XML for storing data is OK, and PDF isn't. XML for printing is not as good - it isn't really very print-friendly. PDF is a better choice for print. It may have a steeper learning curve, but your output will be much nicer. iText is a popular PDF library for Java.

FrustratedWithFormsDesigner
  • 46,105
  • 7
  • 126
  • 176
  • 1
    While XML isn't very printer friendly, you could use XSLT to transform it into a format which is. – Oliver Weiler Jul 07 '11 at 14:33
  • @Oliver Weiler: A good point, though if the OP is coding in Java, I'd just suggest they use iText to output PDF directly. I admit, I don't really like XSLT and avoid it when I can. This sounded simple enough that XSLT would have just complicated it further (unless iText can take in XML+XSLT and produce PDF - if it can then I'd consider it more seriously). – FrustratedWithFormsDesigner Jul 07 '11 at 14:40
  • +1 I don't like it either, and iText seems to be pretty good (haven't worked with it yet but heard only good things). I just wanted to point out that this option exists :-). – Oliver Weiler Jul 07 '11 at 14:57
9

Why don't you use a simple CSV file?

It's easy to manipulate this file format through programming (there's a ton of libraries) and can be open by most spreadsheet applications.

Loïc Lopes
  • 839
  • 1
  • 6
  • 9
  • It sounds like OP wants a pre-formatted output, which CSV doesn't really give. CSV contains no formatting information and can sometimes print really horribly depending on the data (if any values contain line-breaks, if there are too many columns to fit the page, if the viewer app such as Excel truncates data,...) – FrustratedWithFormsDesigner Jul 07 '11 at 14:19
  • Thanks. Looking into this. I just need the info to be downloaded and printed so the users can take the frequencies with them when out listening to aircraft. – NeonLinux Jul 07 '11 at 14:19
  • 6
    Beware. In Excel, there is a hidden [Clippy](http://en.wikipedia.org/wiki/Clippy) lurking, which just loves to mangle CSV-data with leading zeroes (like phone numbers or zip codes in scientific notation). – Maglob Jul 07 '11 at 19:53
5

If you want other people to use these radio frequencies in their own applications, store them in a well-formed XML (and include a schema as well). If you just want them to be referred to (i.e. display-only), a PDF or other document would suffice.

Bernard
  • 8,859
  • 31
  • 40
5

I'd just use HTML. It can be formatted for printing using CSS, a table can be copy-pasted into a spreadsheet, it's an open format and it's easy to generate.

André Paramés
  • 343
  • 1
  • 6
  • +1. You can even specify different CSS styles to be applied when the document is printed, in case the data needs to be reformatted. – TMN Jul 08 '11 at 17:22
1

Store the data in the database's native, natural format, whatever it is - table of types that match the values, float for frequency, varchar for name etc.

Extract the data from the database in whatever format is comfortable to transport and process. JSON tends to be much easier to process than XML.

Parse the data on client side and present as a nice HTML table in a neat printer-friendly HTML page. You can even include a nice "Print" button and make it invisible by @media:print{ #printbutton{display:none;} }

Don't lock down access to the list-producing script, allow other pages or engines to pull data from it and keeping it straightforward, so that people who want it in other media than printing your page can use it too - say, auto-update channel list in a web-enabled radio.

SF.
  • 5,078
  • 2
  • 24
  • 36