| ID | Asunto | Fecha | Nick | |
| 52132 | Como imprimir bien esto | 15/03/10 16:21 | lukasgatsu | |  |
Hola buenas!! Comento mi problemilla. Tengo un TextBox que mando a imprimir, imprime todas las lineas, pero con algun errorcillo, cuando una linea es mas ancha que el "papel" baja una linea el texto restante, pero sobreescribiendo la linea siguiente. Este es el codigo:
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim lineasPorPag As Single Dim posY As Single Dim fuente As Font = TextBox1.Font Dim altoFuente As Single = fuente.GetHeight(e.Graphics) lineasPorPag = e.MarginBounds.Height / altoFuente Dim lineasImpresasPorPag As Double = 0 Dim areaAlto As Integer = PrintDocument1.DefaultPageSettings.PaperSize.Height - PrintDocument1.DefaultPageSettings.Margins.Top - PrintDocument1.DefaultPageSettings.Margins.Bottom Dim areaAncho As Integer = PrintDocument1.DefaultPageSettings.PaperSize.Width - PrintDocument1.DefaultPageSettings.Margins.Left - PrintDocument1.DefaultPageSettings.Margins.Right Dim margenIzquierdo As Integer = PrintDocument1.DefaultPageSettings.Margins.Left Dim margenSuperior As Integer = PrintDocument1.DefaultPageSettings.Margins.Top Dim formato As New StringFormat(StringFormatFlags.LineLimit)
While totalLineasImpresas < linea.Length And lineasImpresasPorPag < lineasPorPag posY = margenSuperior + (lineasImpresasPorPag * altoFuente) e.Graphics.DrawString(linea(totalLineasImpresas), fuente, Brushes.Black, New RectangleF(margenIzquierdo, posY, areaAncho, areaAlto), formato) lineasImpresasPorPag += 0.5 totalLineasImpresas += 1 End While
If totalLineasImpresas < linea.Length Then e.HasMorePages = True Else e.HasMorePages = False End If
End Sub
Para aclarar algun punto no duden en avisarme.
Gracias foreros! |
|
| ID | Asunto | Fecha | Nick | |
| 53957 | Re: Como imprimir bien esto (Resp: 52132) | 24/09/10 17:47 | sistemas | | |
Prueba a medir lo que vas a imprimir antes de imprimirlo así:
Dim Medida As SizeF Medida = e.Graphics.MeasureString(Texto, Fuente) e.Graphics.DrawString(Texto, Fuente, Brushes.Black, 40 - Medida.Width / 2, PosicionY)
Aquí imprimies el texto centrado alrededor de la posición 40.
Si esta respuesta resuelve tu duda, por favor pulsa en la de este mensaje. Gracias. |
|
| ID | Asunto | Fecha | Nick | |
| 54195 | Re: Como imprimir bien esto (Resp: 53957) | 10/11/10 12:50 | lukasgatsu | |  |
Gracias por tu ayuda, pero al final lo he solucionado asi:
Dim formato As New StringFormat(StringFormatFlags.NoWrap)
Si esta respuesta resuelve tu duda, por favor pulsa en la de este mensaje. Gracias. |