1

I have a timetable in memory, and need to be able to print it out.

The timetable will likely be many pages, each page will look quite similar: A grid of cells, across the horizontal axis is time, and along the vertical axis is entities. Cell x, y will contain the allocation of a particular job to entity x at timeslot y.

I'm looking at the System.Drawing.Printing.PrintDocument class but it's incredibly cumbersome. I need to set an event handler to the PrintDocument.PrintPage, yet there doesn't appear to be any way to get the page number from the PrintPageEventArgs?

I just want to construct my document and call some Print() function. I suppose if I could get the page number within the event handler, I could construct the page layout on the fly with e.Graphics and GDI.

I could potentially even put together a HTML page using tables and print that - if I could somehow control what prints on what page?

Is there a better way to construct and print documents in C#?

The target machines do have Office installed, but they're all different versions and I've had lots of trouble getting correct versions of the .Net/Office interop library to work with them.

Edit: I could potentially even create a temporary LaTeX file on the fly and compile it, then print it. This seems like a good solution, except that the target machines are locked and the users can't install new software, hence I would need to bundle the LaTeX compiler with my program, and my compiler is almost 300MB.

Ozzah
  • 10,631
  • 16
  • 77
  • 116

3 Answers3

1

I build a similar tool by using the Microsoft Chart Controls, easy to use.

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=130f7986-bf49-4fe5-9ca8-910ae6ea442c&displaylang=en

Erre Efe
  • 15,387
  • 10
  • 45
  • 77
  • I have used MSCharts before - it's included in .Net 4. I don't think MSCharts can make a grid of text to be printed? Perhaps you may have misunderstood the question? Can someone please confirm. – Ozzah Jun 17 '11 at 01:33
1

If you can save it to a file, you can use this here,

Print images c#.net

Community
  • 1
  • 1
Chuck Savage
  • 11,775
  • 6
  • 49
  • 69
1

Sounds to me like you're giving up too soon. Handling the PrintPage event isn't that difficult and since the event is raised sequentially, all you have to do is keep a page counter in that event. That's how I've done it in the past with MetaFile images (printing Reporting Services reports through a web service call).

Jacob Proffitt
  • 12,664
  • 3
  • 41
  • 47
  • Actually I haven't given up, I've been working on the PrintDocument method all day because I haven't found a viable alternative. :) And yes, I'm keeping a page counter like you are. – Ozzah Jun 17 '11 at 05:12
  • :). Yeah, I tried to find an alternative for a long time, too. – Jacob Proffitt Jun 17 '11 at 06:41