a_jam_sandwich Posted December 16, 2002 Posted December 16, 2002 How the hec do you print a rich text box formatted Andy :confused: Quote Code today gone tomorrow!
*Gurus* divil Posted December 16, 2002 *Gurus* Posted December 16, 2002 http://www.c-sharpcorner.com/Code/2002/Oct/ColorSyntaxEditor.asp Looks like this guy has managed it. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
a_jam_sandwich Posted December 16, 2002 Author Posted December 16, 2002 Cheers will look Quote Code today gone tomorrow!
a_jam_sandwich Posted December 17, 2002 Author Posted December 17, 2002 Ive come up with this so far pretty unstructured as yet but works slow. Private Sub pdoc_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles pdoc.PrintPage Dim iMargin As Integer = 15 Dim margin As Integer = 10 Dim i As Integer = 0 Dim theWord As String = "" Dim iPos As Integer Dim TextLine As String Dim bLine As Boolean = False Dim fmt As New StringFormat() fmt.FormatFlags = StringFormatFlags.LineLimit Printer.PrinterSettings.DefaultPageSettings.Margins.Left = 75 Printer.PrinterSettings.DefaultPageSettings.Margins.Right = 75 Printer.PrinterSettings.DefaultPageSettings.Margins.Top = 40 Printer.PrinterSettings.DefaultPageSettings.Margins.Bottom = 40 Dim rectPrintingArea As New RectangleF(Printer.PrinterSettings.DefaultPageSettings.Margins.Left, _ Printer.PrinterSettings.DefaultPageSettings.Margins.Top, _ Printer.PrinterSettings.DefaultPageSettings.Margins.Right - Printer.PrinterSettings.DefaultPageSettings.Margins.Left, _ Printer.PrinterSettings.DefaultPageSettings.Margins.Bottom - Printer.PrinterSettings.DefaultPageSettings.Margins.Top) Dim xPos As Integer = Printer.PrinterSettings.DefaultPageSettings.Margins.Left Dim yPos As Integer = Printer.PrinterSettings.DefaultPageSettings.Margins.Top For i = 0 To RTB.Text.Length RTB.Select(i, 1) Dim sChar As Char = RTB.SelectedText Dim cColor As Color = RTB.SelectionColor Dim fFont As Font = RTB.SelectionFont Dim iHeight As Integer = fFont.Height Dim theSize As New SizeF(e.Graphics.MeasureString(theWord, fFont)) If Asc(sChar) = 10 Then e.Graphics.DrawString(theWord, fFont, New SolidBrush(cColor), xPos, yPos) xPos += Int(theSize.Width) theWord = "" xPos = Printer.PrinterSettings.DefaultPageSettings.Margins.Left yPos += iHeight + 3 ElseIf Not Asc(sChar) = 32 Or Asc(sChar) = 10 Or Asc(sChar) = 8 Then theWord = theWord & sChar Else If (xPos + theSize.Width > (Printer.PrinterSettings.DefaultPageSettings.PaperSize.Width - 75)) Then xPos = Printer.PrinterSettings.DefaultPageSettings.Margins.Left yPos += iHeight + 3 End If e.Graphics.DrawString(theWord, fFont, New SolidBrush(cColor), xPos, yPos) xPos += Int(theSize.Width) theWord = "" End If Next End Sub :) Needs support for multipage Quote Code today gone tomorrow!
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.