By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,712 Members | 1,540 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,712 IT Pros & Developers. It's quick & easy.

Printing a mix of tables and other text

P: n/a
I was wondering if someone could suggest were/how I could get started with
setting up printing of a collection of text that includes tables from a grid
and other supporting information about the grid's contents. If you could
just point me at the classes that I should consider and some very broad
guidelines that would be great. For instances, would a good approach be to
build an rich text document somehow with the proper formatting and then
print that? I would really like to print the grid stuff as tables with lines
marking the grid.

Thanks,

Dennis
Nov 15 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Actually I'm working on a solution to your exact problem right now. I don't
suppose you're in a situation to be able to make "free" improvements to my
code or work with me on i (keeping the final result completely free for
other's to use)? Anyway, depending on your timeline I can either just send
you what I have right now so you can look it over to get some ideas, etc.
Or if you want to give me a deadline of say 4 days, I can get my *** in gear
and get it posted to my website. I think I just need about 16 quality hours
on it to clean it up to be beta quality. Then another 8 hours or so to
clean up documentation. This is a work-in-progress for over a month (off
and on) and can handle:

printing of datatable's (using classes somewhat akin to the
DataGridColumnStyle class for formatting)
printing of paragraphs of data using style classes (somewhat akin to word's
H1, H2, H3, Normal, etc)
page headers/footers
Hopefully will include graphics/images at some point, too (utilizing the
..NET Image class).
Alternatively, have a look at this (vb.net) article. It was my inspiration
(don't worry, my code is C#):
http://msdn.microsoft.com/library/de...ntwinforms.asp

And other articles of varying quality:
Good intro to the printing namespace
http://msdn.microsoft.com/msdnmag/is...T/default.aspx
simple printing of datagrid
http://msdn.microsoft.com/library/de...ridvisualc.asp
other printing things:
http://www.c-sharpcorner.com/Printing.asp

--
Mike Mayer
http://www.mag37.com/csharp/
mi**@mag37.com
"Dennis C. Drumm" <de*******@primacode.com> wrote in message
news:u0**************@TK2MSFTNGP11.phx.gbl...
I was wondering if someone could suggest were/how I could get started with
setting up printing of a collection of text that includes tables from a grid and other supporting information about the grid's contents. If you could
just point me at the classes that I should consider and some very broad
guidelines that would be great. For instances, would a good approach be to
build an rich text document somehow with the proper formatting and then
print that? I would really like to print the grid stuff as tables with lines marking the grid.

Thanks,

Dennis

Nov 15 '05 #2

P: n/a
"Kieran Benton" <ki****@teejpc.homeip.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Michael,

Sounds like a class act idea! Dont suppose you could let us all know when
u've posted the code? I implemented something a bit like this for a project over a year ago but never made it "production" (lol) quality and there were quite a few limitations to it (Though it did what it needed to at the time).

Actually, I read something that recommended exactly what you did. They said
unless you are REALLY prepared to solve a general problem, don't. Because a
half-baked attempt at solving a general problem with only your specific
problem in mind will only do two things:
1) make your specific solution more complicated than it should be
2) waste time by developing more code than you need
without really ever solving the general problem. (And that a lot of rewrite
will be required to solve the general problem.)

However, I was already 50% towards solving my problem (with a, hopefully,
generic approach) so I ignored the advice. Then I proceeded to rewrite it
all to be more generic. I'm on about the third rewrite and I believe that
will the final major overhaul - I feel it's a farily stable
platform/framework. I'm sure the first person to use my code will find that
it doesn't fit their needs near as well as it fit mine and that might
inspire another major rewrite. ugh!
If possible I might be able to contribute? Building it from a dataset sounds like a damn good design decision, and I never even thought of it!


Sure thing I will post it. I'm tempted to post it under GPL so that all
modifications can further help others. However, I have no problem if people
use the library in a commercial app, I just want any modifications to the
library itself to remain open and free. So I need to read up on licensing a
bit before I post anything. Any comments on licensing schemes that work
well for such a thing?

I only made an hour of progress today, in between other misc tasks. But I
was surprised at how much I got done, despite the fact that I haven't looked
at the code for about a month now.

Here's a quick teaser page (with a teaser app).
http://www.mag37.com/csharp/articles/Printing/

I'll probably update it daily over the next week, so check back often!

--
Mike Mayer
http://www.mag37.com/csharp/
mi**@mag37.com
Nov 15 '05 #3

P: n/a
The first public version of "ReportPrinting" is now released. This is
beta-code. Maybe not even that. It works for me, but I'm curious to see
reactions from others.

http://www.mag37.com/csharp/articles/Printing/

I'll work on getting a simple tutorial up and running. For now, I'd suggest
reading the two links under Documentation, and then looking through the 5
"ReportTest" documents included in the project. There's a lot of NDoc'ed
docs as well.

Send me any questions / comments at the address below.

--
Mike Mayer
http://www.mag37.com/csharp/
mi**@mag37.com
Nov 15 '05 #4

P: n/a
Looks extremely professional and fully featured Michael! Sorry havent had
too much time to look at the code as Im a poor student and having to work
hard to pay off last terms debt :p Will have a better rummage when I can
although it looks pretty quick to generate a report from a small amount of
code.

This is basically what I've been looking for, a very cut down version of
crystal but without the bells and whistles. Oh by the way, have you managed
to solve the age old .NET printing problem of working out how many pages are
in a document so that you can do a Page 1 of 5 or whatever? That one had me
stumped for ages...

Kieran
"Michael Mayer" <mi**@mag37.com> wrote in message
news:eq**************@TK2MSFTNGP12.phx.gbl...
The first public version of "ReportPrinting" is now released. This is
beta-code. Maybe not even that. It works for me, but I'm curious to see
reactions from others.

http://www.mag37.com/csharp/articles/Printing/

I'll work on getting a simple tutorial up and running. For now, I'd suggest reading the two links under Documentation, and then looking through the 5
"ReportTest" documents included in the project. There's a lot of NDoc'ed
docs as well.

Send me any questions / comments at the address below.

--
Mike Mayer
http://www.mag37.com/csharp/
mi**@mag37.com

Nov 15 '05 #5

P: n/a
"Kieran Benton" <ki**********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Looks extremely professional and fully featured Michael! Sorry havent had
too much time to look at the code as Im a poor student and having to work
hard to pay off last terms debt :p Will have a better rummage when I can
although it looks pretty quick to generate a report from a small amount of
code.
This is basically what I've been looking for, a very cut down version of
crystal but without the bells and whistles.
Thanks for the compliment.
Oh by the way, have you managed
to solve the age old .NET printing problem of working out how many pages are in a document so that you can do a Page 1 of 5 or whatever? That one had me stumped for ages...


No, I haven't figured that one out. Everything that comes to mind now seems
like a big pain in the butt. Any suggestions?

--
Mike Mayer
http://www.mag37.com/csharp/
mi**@mag37.com


Nov 15 '05 #6

P: n/a
There are only two ways of doing this as far as I can see:

1. Do a behind the scenes printpreview before any printing operation and
check how many pages you have (big pain in butt and not exactly elegant)

2. Calculate how much space everything will take up before you even begin
printing (horrendously big pain in the butt but slightly more elegant)

Does anyone else have any ideas?

Regards,
Kieran

"Michael Mayer" <mi**@mag37.com> wrote in message
news:uS*************@TK2MSFTNGP10.phx.gbl...
"Kieran Benton" <ki**********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Looks extremely professional and fully featured Michael! Sorry havent had too much time to look at the code as Im a poor student and having to work hard to pay off last terms debt :p Will have a better rummage when I can
although it looks pretty quick to generate a report from a small amount of code.
This is basically what I've been looking for, a very cut down version of
crystal but without the bells and whistles.
Thanks for the compliment.
Oh by the way, have you managed
to solve the age old .NET printing problem of working out how many pages

are
in a document so that you can do a Page 1 of 5 or whatever? That one had

me
stumped for ages...


No, I haven't figured that one out. Everything that comes to mind now

seems like a big pain in the butt. Any suggestions?

--
Mike Mayer
http://www.mag37.com/csharp/
mi**@mag37.com

Nov 15 '05 #7

P: n/a
Well, I just released version 0.3. Much better than pervious versions (if I
do say so myself). Let me know of any comments you have (if you are using
it or not, etc)

Current release ver. 0.3, 5-Sep-03
http://www.mag37.com/csharp/articles/Printing/

Quite a few fixes:
Fixed PageFooter problem (they became headers).
Completely reorganized the call structure of ReportSection. Separated sizing
from printing methods. Cleaned up a lot of code.
Added ReportSectionLine
Added ability to do columns of text.
Added Margins to abstract ReportSection class.
Orphaned header rows shouldn't print (untested).

--
Mike Mayer
http://www.mag37.com/csharp/
mi**@mag37.com
"Dennis C. Drumm" <de*******@primacode.com> wrote in message
news:u0**************@TK2MSFTNGP11.phx.gbl...
I was wondering if someone could suggest were/how I could get started with
setting up printing of a collection of text that includes tables from a grid and other supporting information about the grid's contents. If you could
just point me at the classes that I should consider and some very broad
guidelines that would be great. For instances, would a good approach be to
build an rich text document somehow with the proper formatting and then
print that? I would really like to print the grid stuff as tables with lines marking the grid.

Thanks,

Dennis

Nov 15 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.