print preview dialogue only shows the last seven pages out of twenty

aewarnick

Senior Contributor
Joined
Jan 29, 2003
Messages
1,031
Code:
		private void printDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
		{
			int charsFilled=0, linesFilled=0;
			string text= this.RTB.Text.Substring(   , RTB.Text.Length-   );

			e.Graphics.MeasureString(text,
				this.RTB.Font, new SizeF(e.MarginBounds.Width, e.MarginBounds.Height), 
				new StringFormat(StringFormatFlags.LineLimit), out charsFilled, out linesFilled);
			
			e.Graphics.DrawString(text, this.RTB.Font, Brushes.Red, e.MarginBounds, new StringFormat(StringFormatFlags.LineLimit) );
			
			   =    +charsFilled;
			if(    < this.RTB.Text.Length) { ++   ;  e.HasMorePages=true; }
			else {e.HasMorePages=false;    =0;}
		}


This method works perfectly for documents that are not 82,000 characters long. The one document I have is 82,000 characters long and the print preview dialog shows the first 12 pages blank, yet the last 8 pages are okay.

But even worse is when I try to print. It sends all the pages including the blanks that should not be blank and starts printing not even on the 1st filled page, which is 13, but on page 15!!

What is wrong here?
 
Last edited:
Back
Top