Tema: imprimir c#
Ver Mensaje Individual
  #2 (permalink)  
Antiguo 30/06/2008, 15:59
Avatar de Peterpay
Peterpay
Colaborador
 
Fecha de Ingreso: septiembre-2007
Ubicación: San Francisco, United States
Mensajes: 3.858
Antigüedad: 16 años, 7 meses
Puntos: 87
Respuesta: imprimir c#

En tu manejador del evento imprimir de tu printdocument en mi caso

private void MyPrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
int topMargin = printDocument1.DefaultPageSettings.Margins.Top;
int leftMargin = printDocument1.DefaultPageSettings.Margins.Left;
float linesPerPage = 0;
float verticalPosition = 0;
float horizontalPosition = leftMargin;
string textLine = null;
int currentLine = 0;
linesPerPage = 66;

while (currentLine < linesPerPage)
{
textLine = (aqui va tu fuente de lineas de texto de tu documento, una coleccion o un stream o q se yo pero q contenga todas las lineas de texto)
if(textLine == null)
{
break;
}

verticalPosition = topMargin + currentLine * myFont.GetHeight(e.Graphics);

e.Graphics.DrawString(textLine, myFont, myBrush, horizontalPosition, verticalPosition);
currentLine += 1;
}

if (textLine != null)
{
e.HasMorePages = true;
}
else
{
e.HasMorePages = false;
}
}

RECUERDA Q EL EVENTO PRINT SIGUE ACTUANDO HASTA Q E.HASMOREPAGES SEA FALSO
__________________
Curso WF4
http://cursos.gurudotnet.com/ DF
Aprende HTML5