Printing mit Print Dialog -> neues Blatt ?

Code:
private float lpp = 0;
private float yPos = 0;
private int count = 0;
private float leftMargin = 0;
private float topMargin = 0;
private string line = null;
private string[] testtext = new string[1001];
private Font printFont;
private int sitenumber = 1;
private int linecount = 0;
 
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
//Work out the number of lines per page 
//Use the MarginBounds on the event to do this
lpp = e.MarginBounds.Height / printFont.GetHeight(e.Graphics);
//Now iterate over the file printing out each line 
//NOTE WELL: This assumes that a single line is not wider than the page width 
//Check count first so that we don't read line that we won't print 
while (count < (lpp*sitenumber) && ((line = testtext[count]) != null))
{
yPos = topMargin + (linecount * printFont.GetHeight(e.Graphics));
//Print Preview control will not work.
e.Graphics.DrawString(testtext[count], printFont, Brushes.Black, leftMargin,
yPos, new StringFormat());
linecount++;
count++;
}
//If we have more lines then print another page 
if (line != null)
{
linecount = 0;
sitenumber++;
e.HasMorePages = true;
}
else
e.HasMorePages = false; 
}
private void Form1_Load(object sender, EventArgs e)
{
printFont = new Font("Arial", 10);
lpp = 0;
yPos = 0;
count = 0;
linecount = 0;
leftMargin = 20;
topMargin = 40;
line = null;
for (int i = 0; i < 1000; i++)
testtext[i] = i.ToString();
testtext[700] = null;
printPREdoc.Document = printdoc;
printPREdoc.SetBounds(0, 0, 1024, 768);
printPREdoc.ShowDialog();
}


Für alle die auch mal so ein Abge****tes Problem haben wie ich ;)
Oben ist der Code, der funktioniert... Ist nur nen Testcode, Bezeichner oder sowas mach ich an Wochenenden (und Montag morgens ist noch Wochenende ;) ) nicht.

Nörgler wenden sich bitte an meine Mail Addi -> Nörgler@Papierkorb.de

Wünsch euch nen schönen Tach und dir Norbert, nochmal danke für deine Hilfe !

Gruss

MFC OpenGL
 

Neue Beiträge

Zurück