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?

1
  • 25
    XML isn't required for anything... :)
    – Fosco
    Jul 7, 2011 at 14:13

5 Answers 5

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.

3
  • 1
    While XML isn't very printer friendly, you could use XSLT to transform it into a format which is. Jul 7, 2011 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). Jul 7, 2011 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 :-). Jul 7, 2011 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.

3
  • 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,...) Jul 7, 2011 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 7, 2011 at 14:19
  • 6
    Beware. In Excel, there is a hidden Clippy lurking, which just loves to mangle CSV-data with leading zeroes (like phone numbers or zip codes in scientific notation).
    – Maglob
    Jul 7, 2011 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.

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.

1
  • +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 8, 2011 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.