Ok, so here is the thing. I wanna print some text on more pages, text that would be inserted by the user in a textbox (jest to have an image).. I ll give you a simple example of what i am trying to do:
on a click of a button i wanna call a print preview dialog (here is how):
private void button2_Click(object sender, EventArgs e)
{
printPreviewDialog1.Document = printDocument1;
printPreviewDialog1.ShowDialog();
}
After this in printdocument i am doing this: (not the real code, jest a little example)
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
Font myFont = new Font("m_svoboda", 14, FontStyle.Underline, GraphicsUnit.Point);
int y = e.MarginBounds.Top;
for (int i=0; i<70; i++)
{
e.Graphics.DrawString("TEST", myFont, Brushes.Black, new PointF(e.MarginBounds.Left, y));
y += 35;
}
}
So, like this it will not write all 70 lines, so it needs to open a new page.. But HOW to do it.. I have try with "e.HasMorePages", but no success with it. So please if someone knows how to solve this problem, let me know..
(solving this simple example would help me very very much!)..
EDIT:
Thanks for the response. But i still cant solve this.. I have already seen that, but it's little complicated to me (didn't mention that i am beginner)
Like for example, in that project i don't know what is/do "StreamReader streamToPrint", so it jest confuses me..
Here is what i tried (what i thought that would be correct):
private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
{
Font myFont = new Font("m_svoboda", 14, FontStyle.Underline, GraphicsUnit.Point);
int y = e.MarginBounds.Top;
for (int i = 0; i < 70; i++)
{
if (y >= e.MarginBounds.Bottom)
{
e.HasMorePages = true;
y = e.MarginBounds.Top;
}
else
{
e.HasMorePages = false;
e.Graphics.DrawString("TEST", myFont, Brushes.Black, new PointF(e.MarginBounds.Left, y));
y += 25;
}
}
}
But this doesn't work..
Now if you(anyone) could write me the code where 70 lines of the word TEST would be written, one under another, on several pages as it is needed.. or any number of words, i jest need the compiler to know how many new pages should open, and write the wanted text in the wanted page..
I hope you could understand me what i wanna know, and that you ll help me..
Thanks you Forward..
Last Edit: It is great now. Thank you Nick..