title: Efficient way to count number of pages to print?
body: <p><strong>TLDR</strong>
  How can one efficiently determine the amount of pages that have to be printed?</p>
  
  <p>** Just a note: I marked klugerama's answer as the answer to my question. I'm still open for other suggestions though!</p>
  
  <p>Currently, I have an application in production which prints invoices. The printing itself isn't a problem: customer information, invoice details etc are printed as they should be. However, users are complaining about the time it takes my software to send the print job to the printer.</p>
  
  <p>At the moment, I have implemented a rather inefficient way to print. In order to know how many pages I have to print, I do a 'dry run' of the print job and cancel it before it gets sent to the printer. Then I count the number of pages the print job contains and add that information to the print job that actually does get sent to the printer. To do this, I 'abuse' the <a href="http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.printpage%28v=vs.71%29.aspx" rel="nofollow">PrintDocument.PrintPage</a> method. After doing so, I can print "Page 1/2 - Page 2/2" etc.</p>
  
  <p>I'm currently thinking about handling this in a different way. I know which margins I have in a page, like the header and the footer. Ergo, the space between header and footer is the available space to print article information (name, price etc). If I calculate the height of the string (using <a href="http://msdn.microsoft.com/en-us/library/6xe5hazb.aspx" rel="nofollow">Graphics.MeasureString</a>), I can tell when the articles take up more space on a page that's available for printing.</p>
  
  <p>Previously, printing could take up to a minute before actually getting sent to the printer (taken into account the clients which run the software aren't the fastest around). I have implemented this method, and printing now takes about 5-10 seconds. However, I'm wondering if this is the way to go. I can't imagine I'm the only one dealing with this issue; how do you deal with this?</p>
  
  <p>I'm also open to completely different approaches.</p>