Thread: Formatted output format suitable for printing

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    125

    Formatted output format suitable for printing

    This is a fairly open question so it may seem a bit odd, but it also means I have very little idea where to start.
    Basically, I've written a program (programmed in C++, runs under windows) to practice japanese kanji, and now I would like to make the program use the database I'm building along with it to produce printable documents to revise when I'm away from the PC, i.e. a sheet of paper with all the kanji of one lesson along with their translation+readings organised neatly. (an example of the kind of layout I'd like to print is attached)
    The problem is, I can't seem to find a suitable file format or markup language to write these files in.

    So far I've looked at
    1. LaTeX, which seems simple and very printable, but appears to have incredibly poor support for tables of any kind plus seems to be somewhat hard to get to work with unicode (necessary to get the kanji in)
    2. RTF, no support for tables whatsoever? Only real documentation I could find was the official 200+ page specification.
    3. HTML, very easy to get the layout to work on-screen but it seems unsuitable for printing (no clear control over the position of stuff on paper), plus I can't seem to change the font of any non-roman character (i.e. the kanji themselves look very ugly) even though I have several fonts with a full CJK character set installed.
    4. Any bitmap format: full control over the final print, but the files would end up being very large even for low DPI and I'd have to write code to do all of the rendering/rasterising myself.

    So far none of these options seem viable.
    Any suggestions for easily formatting something like in the attachment would be greatly appreciated!

    (edit: any way to not display attached images automatically? It's kind of... big. Especially considering it's only an example of what I want to do)
    Last edited by Boksha; 01-03-2007 at 03:17 PM.
    Typing stuff in Code::Blocks 8.02, compiling stuff with MinGW 3.4.5.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Well the postscript language is directly supported by all but the cheapest of printers, and it has full control over how the page is laid out.

    It's pretty easy to write as well (especially from code). To something which doesn't understand postscript, it's just a regular text file (so it's easy to check by visual inspection).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    You may also want to revise your understanding of the RTF. It does support tables. You may have skipped it because there's no table group. However they are there. They are instead defined as properties of the paragraph elements. It doesn't make it more complex. In fact, I wish HTML had been defined the same way. Check the specification on the web.

    Postscript or RTF are both excellent choices for your project.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  4. #4
    Registered User
    Join Date
    Mar 2002
    Posts
    125
    Actually Mario, before today I had no understanding whatsoever of any of the formats I mentioned (excluding, perhaps, HTML). The same goes for Postscript.

    Anyway, thanks for the replies so far.
    Looking at the postscript and RTF documentation, it appears to me that either way getting my program to output printable pages is going to be at least as much work as writing the entire program and learning the Windows API combined. It's a bit daunting at the moment, especially considering writing this program is just a sideproject of a hobby.
    I'm currently trying to figure out how to get the kanji in a postscript file, but doing so appears incredibly hard to me at the moment, even if I have the unicode numbers of the characters. The documentation goes around slinging all sorts of terms about I haven't encountered before (font library? CID font? CMAP?), and when I search on Google how to get unicode text into a postscript file, I'm getting the weirdest results. Any info on that would be greatly appreciated.
    Typing stuff in Code::Blocks 8.02, compiling stuff with MinGW 3.4.5.

  5. #5
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Well in that case I would perhaps suggest you drop Postscript for now. You will feel more at ease with RTF since it's basically a markup language, whereas PostScript is more of a programming language with a steep learning curve in comparison.

    The web offers lots of easy introductions into RTF and the Specification alone is an excellent document. I once had to develop a project that generated RTF based accounting reports. I had no knowledge of RTF prior to that. Took me one day to produce a basic report and two more to finish it. It's that easy to learn.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  6. #6
    Registered User
    Join Date
    Jan 2007
    Posts
    40
    3. HTML, very easy to get the layout to work on-screen but it seems unsuitable for printing (no clear control over the position of stuff on paper), plus I can't seem to change the font of any non-roman character (i.e. the kanji themselves look very ugly) even though I have several fonts with a full CJK character set installed.
    You can link CSS files specific for printing. Excellent article on using CSS for print: http://alistapart.com/articles/goingtoprint/ . Or just 'google' "CSS printing".

  7. #7
    Registered User
    Join Date
    Mar 2002
    Posts
    125
    Ah, after a lot of searching and some tinkering with RTF documents, I managed to create a non-code-bloated (the RTF code MS Word puts out scares me ) table with vertically merged cells by hand. Getting fonts and unicode in an RTF file is well documented, so implementing this in my program looks to be smooth sailing from here. Thanks a lot for the help!
    Typing stuff in Code::Blocks 8.02, compiling stuff with MinGW 3.4.5.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help fixing bugs in data parsing program
    By daluu in forum C Programming
    Replies: 8
    Last Post: 03-27-2003, 06:02 PM
  2. Control different DA output value!
    By Hunterhunter in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 03-13-2003, 12:11 PM
  3. File Input / Output Help?
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 05-18-2002, 10:20 AM
  4. formatted file output
    By ronin in forum C++ Programming
    Replies: 2
    Last Post: 02-09-2002, 10:38 AM
  5. To all who read last post formatted output
    By spliff in forum C Programming
    Replies: 8
    Last Post: 08-21-2001, 03:37 AM