开发者

Formatting plain text output for printing?

开发者 https://www.devze.com 2022-12-12 19:39 出处:网络
I have a program that outputs a report into plain text. The report must be plain text for it to load into a third party program. The report also needs to be printable.

I have a program that outputs a report into plain text. The report must be plain text for it to load into a third party program. The report also needs to be printable.

When dealing with plain text, what limits s开发者_StackOverflow社区hould I set on line size and number of lines on a page to get it to print reasonably?


It definitely depends on the font you use when printing, and unless you have control over that you can't guarantee it will print nicely. For example, in Word 2007, creating a blank document and setting the font to Courier New 10pt only fits 77 characters per line and 28 lines per page. Changing the margins and line spacing will modify that. However if you used that and they tried to print from Wordpad it wouldn't work because the default with Courier New 10pt only fits 72 characters per line. In either case, the standard 80 characters doesn't work. Those defaults aren't even global defaults.

The best you can probably do is pick a size and provide instructions on printing the report with several common editors so it will look acceptable. Specify the font, margin, line spacing, etc.

Have you considered other options, like creating two files? One could be plain text for import into the other program. The other could be a format better suited for printing.


its going to depend on your printing font, you want to aim for a fixed width font so that it is consistent, 80 columns is generally safe.... i think....

edit: here is a quick guide I googled - http://dsl.org/cookbook/cookbook_17.html


If you have control over the output format, consider a lightweight WYSIWYG markup language, Such as reStructuredText, AsciiDoc, markdown etc.

This way you can pipe the plane-text format into a converter that will result in postscript, PDF or HTML, that you can then print. This also mostly negates the need to consider the line width for the sake of your printer. The converter will do this for you.

0

精彩评论

暂无评论...
验证码 换一张
取 消