Outputting a table for print...

This is a discussion on Outputting a table for print... within the C++ Programming forums, part of the General Programming Boards category; Okay, I want to output something in a grid or table suitable for print, and if possible I want to ...

  1. #1
    Registered User guesst's Avatar
    Join Date
    Feb 2008
    Location
    Lehi, UT
    Posts
    179

    Outputting a table for print...

    Okay, I want to output something in a grid or table suitable for print, and if possible I want to do so without relying on external libraries.

    My immediate solution is to write HTML to an appropriately named text file because I know the codes for that, but it seems to me there must be a better format for this. Any ideas?
    Type-ins are back! Visit Cymon's Games at http://www.cymonsgames.com for a new game every week!

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,532
    You could write them out as postscript files if you want, but that might seem like hard work compared to HTML.

    I take it you're not writing a win32 GUI program then.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User guesst's Avatar
    Join Date
    Feb 2008
    Location
    Lehi, UT
    Posts
    179
    Heh. No, it's actually a Curses application. I wanted something a little more cross-platform.

    If I were writing it in Win32 what format would you recommend?

    I've got to find out how out write out PS files.
    Type-ins are back! Visit Cymon's Games at http://www.cymonsgames.com for a new game every week!

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    <obMaster>LaTeX! LaTeX!</obMaster>
    How fancy is suitable for print? Do you want lines in between, or is .txt with \t fine? (I never seem to get HTML to print properly anyway, so I wouldn't suggest that.) I don't know if there's a Win32 port of *roff (I don't speak *roff anyway).

  5. #5
    Registered User guesst's Avatar
    Join Date
    Feb 2008
    Location
    Lehi, UT
    Posts
    179
    I could do output with tabs myself but I want something a bit prettier. Here, lemme spec it out:
    • A grid drawn with numbers on it.
    • As close to straight C++ as possible. (I'm going to be distributing the code and don't want others to have to install 3rd party libraries any more than necessary)
    • Page breaks would be nice, but not necessary.

    I've got a puzzle generator. It generates puzzles a bit like soduku, but easier (and without the thick lines). Curses is fine while it's running but it doesn't work so good to output as a text file. So I'd like to do something a bit prettier, especially since I assume mass puzzle generation is something that this program will be used primarily for (if it's used at all).

    PS would work great if i could figure out how to do a grid in PS with properly positioned numbers.
    Type-ins are back! Visit Cymon's Games at http://www.cymonsgames.com for a new game every week!

  6. #6
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Quote Originally Posted by tabstop View Post
    LaTeX! LaTeX!
    Ya know... there have been a couple of instances where it would have come in handy just in the past few weeks alone. For sudoku I just don't see any real reason to switch to a GUI interface. I mean you can. But what are you honestly gaining? Its like making a tic-tac-toe game and needing to see it as a pretty GUI. At the end of the day there is only so much you can do to make it look good and it will only be a slight step up above your curses code you have now.

  7. #7
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    I've got a crostic-grid-generator available. It's in Perl (gasp!) but it outputs a Postscript grid, so it may give you some idea of what it should look like. I used LaTeX to deal with putting the numbers in the right places later (this way the font on the numbers matched the font of everything else, rather than a Postscript font), but I don't think it will hurt that much to add.

  8. #8
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Cute.

  9. #9
    Registered User guesst's Avatar
    Join Date
    Feb 2008
    Location
    Lehi, UT
    Posts
    179
    Quote Originally Posted by master5001 View Post
    Ya know... there have been a couple of instances where it would have come in handy just in the past few weeks alone. For sudoku I just don't see any real reason to switch to a GUI interface. I mean you can. But what are you honestly gaining? Its like making a tic-tac-toe game and needing to see it as a pretty GUI. At the end of the day there is only so much you can do to make it look good and it will only be a slight step up above your curses code you have now.
    Hu? Gui interface? No. It's a text interface, Curses in fact. The only part that needs to be pretty is the file output with the puzzles (and solutions) on it. And at that it only need to be prettier than a text file.
    +---+---+---+
    | 1 | _ | _ |
    +---+---+---+
    | _ | 7 | _ |
    +---+---+---+
    | _ | _ | 5 |
    +---+---+---+
    <- Not what I want.

    My problem with LaTeX is it doesn't import well into anything. I'm definitely leaning towards PS, tho navigating the incredible volume of commands and learning the ones I want is daunting. That's okay, this has been a learning process all over for me.
    Type-ins are back! Visit Cymon's Games at http://www.cymonsgames.com for a new game every week!

  10. #10
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Well, I guess the question is "what do you want to import it into?" I don't know what percentage of Win32 systems out there can view .ps files either -- I guess photoshop.

  11. #11
    Registered User guesst's Avatar
    Join Date
    Feb 2008
    Location
    Lehi, UT
    Posts
    179
    Quote Originally Posted by tabstop View Post
    Well, I guess the question is "what do you want to import it into?" I don't know what percentage of Win32 systems out there can view .ps files either -- I guess photoshop.
    Yeah, I'm getting that. PS may work but it may not be the best thing.

    Here's what I want. When I was teaching math I used puzzles on the first day to teach the learning process and I wish I would have had Numbrixs available because they really are very easy. So now I want to make the tool I wish I had then.

    Is there a way to output to a PDF without loading external libraries?
    Type-ins are back! Visit Cymon's Games at http://www.cymonsgames.com for a new game every week!

  12. #12
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by guesst View Post
    Is there a way to output to a PDF without loading external libraries?
    I'm pretty sure the answer to that is "no". epstopdf requires Ghostscript, so far as I can tell, and writing PDF directly is pretty hard, I think. Some Google searching shows some free C libraries that will do the heavy lifting, but you should look at the license to see if it's right for you (presumably it would get compiled in with your program and distributed that way).

  13. #13
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,532
    PS is easy, once you get used to the reverse polish notation.
    Plus they're just text files, so no need for messy libraries.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  14. #14
    Registered User guesst's Avatar
    Join Date
    Feb 2008
    Location
    Lehi, UT
    Posts
    179
    I fell like I'm copping out, but I think for now I'm just going to do a text file. This project has forced me to learn enough. If someone else wanted to write a PS or RTF function I'll gladly add it in.

    The Numbrix Generator will probably show up on my site in a few weeks.
    Type-ins are back! Visit Cymon's Games at http://www.cymonsgames.com for a new game every week!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Hash Table outputting incorrect number
    By Paul Skinner in forum C Programming
    Replies: 4
    Last Post: 11-20-2008, 05:19 AM
  2. Writing array, to file
    By zootreeves in forum C Programming
    Replies: 9
    Last Post: 09-08-2007, 05:06 PM
  3. Outputting to a table
    By cyberCLoWn in forum C++ Programming
    Replies: 4
    Last Post: 02-25-2004, 07:15 PM
  4. extra word printing
    By kashifk in forum C++ Programming
    Replies: 2
    Last Post: 10-25-2003, 04:03 PM
  5. inputting words from a file
    By kashifk in forum C++ Programming
    Replies: 5
    Last Post: 10-24-2003, 07:18 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21