Best way to print data in columnar format?

I am using Python to read data in a user-friendly format and convert it to a more readable format. The entries I have printed will usually be just the last name, first name, and room code. I

I would like to output a series of pages, each containing a contiguous subset of complete records, divided into multiple columns, each containing a contiguous subset of all records on the page. (In other words, you read the first column, move to the next column, move to the next column, etc., and then start on the next page ...)

The problem I am currently facing is that for the output formats I am almost certainly limited to HTML (and Javascript, CSS, etc.). What is the best way to get data in this columnar format? If I knew for sure that the printable area on paper would contain 20 records vertically and five horizontally, for example, I can easily print 5x20 tables, but I don't know if there is a way to indicate a page break - and I don't know if there is a way to calculate programmatically how many records will fit on a page.

How do you approach this?

EDIT: The reason I said I was limited in output: I need to create a file on one computer and then bring it to another computer where we cannot install new software and on which the choice of existing software is not optimal ... The file itself will only be used to create the physical printout (which the end users actually work with), but my time on the computer I can print on will be limited so I need to have the file all ready to print and print right away without much setup ...

Right now, I've managed to find a word processor that I can use on the target machine, so I'll see if I can target the format that the word processor uses.

EDIT: Once I realized there was a word processor I could use, I made a simple skeleton file with the settings I needed (column and tab settings, monospaced font in small dot size, etc.), and then measured how many characters I got per column row and how many rows I got per column. I watched the runs very closely to make sure there weren't any strange lines that somehow overflowed character directives per line (which shouldn't happen with monospaced, of course, but how many times do you eventually need to figure out why does something that "shouldn't" happen anyway?)

If there was no word processor on the target machine that I could use, I would probably look at PDF as the output format.

0


source to share


1 answer


"If I knew for sure that the printable area on paper will contain 20 records vertically and five horizontally."

You know that.

You know the size of your paper. You know the font size. You can do the math easily.

"almost certainly limited to HTML ..." doesn't make much sense. Is this a web application? Can the page have "Previous" and "Next" buttons to navigate through the pages? Select the size that suits you and display one page with "Previous" and "Next" buttons.



If it has to be a single HTML page that prints correctly, it's tricky. There are CSS things you can do, but you'll be happier creating a PDF.

Get PyX or ReportLab and create a PDF that prints correctly.

I - personally - have no patience with any of this. I am trying to put this in a CSV file. Then my users can open the CSV with spreadsheet tools (Open Office Org has a good one) and then customize the columns and print with it.

+3


source







All Articles