Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question
25  
XML isn't required for anything... :) –  Fosco Jul 7 '11 at 14:13
add comment

5 Answers

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.

share|improve this answer
2  
+1 for storage and display being different. –  unholysampler Jul 7 '11 at 14:24
1  
While XML isn't very printer friendly, you could use XSLT to transform it into a format which is. –  Oliver Weiler Jul 7 '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 7 '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 7 '11 at 14:57
add comment

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.

share|improve this answer
    
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 7 '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 7 '11 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 '11 at 19:53
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
    
+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 '11 at 17:22
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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