SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Printing in .NET


Printing in .NET

Author
Message
Colin Hobby
Colin Hobby
Valued Member
Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)

Group: General Forum Members
Points: 58 Visits: 3

Jereme,

here is my PrintObject string.....

Dim MyPrintObject As New TextPrint("<B>Equipment Agreement Form</B>" _

+ vbCrLf + vbCrLf + "<B>Name: </B>" + Trim(oEmployee.LastName) + ", " + Trim(oEmployee.FirstName) + vbCrLf + "<B>Title: </B>" + Trim(oEmployee.Title) + vbCrLf + "<B>Department: </B>" + Trim(oEmployee.Department) + vbCrLf + "<B>Site: </B>" + oEmployee.Site + vbCrLf + "<B>Floor: </B>" + Trim(oEmployee.Floor) + vbCrLf + "<B>Start Date: </B>" + Trim(oEmployee.StartDate) + vbCrLf + "<B>Transfer Date: </B>" + Trim(oEmployee.TransferDate) + vbCrLf + "<B>Termination date: </B>" + oEmployee.TermDate + vbCrLf + "________________________________________________________________________" + vbCrLf + "<B>Room Number: </B>" + Trim(oEmployee.RoomNumber) + vbCrLf + "<B>Telephone: </B>" + Trim(oEmployee.TelephoneLine) + "<B> Extension: </B>" + Trim(oEmployee.Extension) + vbCrLf + "<B>Long Distance Code: </B>" + Trim(oEmployee.LDcode) + vbCrLf + "<B>Meditech Access: </B>" + Trim(oEmployee.MedTechIssu) + "<B> Issue Date: </B>" + Trim(oEmployee.MedTechIssued) + vbCrLf + "<B>PC: </B>" + Trim(oEmployee.PcIssued) + "<B> Issue Date: </B>" + Trim(oEmployee.PCDate) + vbCrLf + "<B>Outlook: </B>" + Trim(oEmployee.EmailIssued) + "<B> Issue Date: </B>" + Trim(oEmployee.EmailIssueDate) + vbCrLf + "<B>Internet: </B>" + Trim(oEmployee.InternetIssued) + "<B> Issue Date: </B>" + Trim(oEmployee.InternetDate) + vbCrLf + "<B>Transcription: </B>" + Trim(oEmployee.TranscriptionID) + "<B> Issue Date: </B>" + Trim(oEmployee.TranscriptionDate) + vbCrLf + "<B>Pager: </B>" + Trim(oEmployee.PagerIssued) + "<B> Issue Date: </B>" + Trim(oEmployee.PagerDate) + vbCrLf + "<B>Cell Phone: </B>" + Trim(oEmployee.CellIssued) + "<B> Issue Date: </B>" + vbCrLf + "<B>Other Equipment: </B>" + vbCrLf + vbCrLf + "<B>Keys: </B>" + vbCrLf + vbCrLf + "<B>Parking Permit: </B>" + Trim(oEmployee.ParkingID) + " <B>Permit Number: </B>" + Trim(oEmployee.PermitNumber) + vbCrLf + "<B>Issue Date: </B>" + Trim(oEmployee.ParkingID) + vbCrLf + "<B>Handicap: </B>" + Trim(oEmployee.handicap) + "<B> Lot Assigned: </B>" + Trim(oEmployee.Lot) + vbCrLf + "<B>Badge: </B>" + Trim(oEmployee.BadgeID) + "<B> Issue Date: </B>" + Trim(oEmployee.BadgeID) + vbCrLf + vbCrLf + "<I>I agree to return items and equipmnet to my department manager at time of termination. Failure to return items or equipment will result in value of items to be withheld from final paychek or accrued leave.</I>" + vbCrLf + "<B>Employee Signature: </B>" + "____________________" + vbCrLf + "<B>Print Name: </B>" + "____________________" + vbCrLf + "<B>Date: </B>" + "______/_____/_________", defPrinter)

this code will print the Bolded line as ....( and in Italics too)

" ag ee o e u n ems an equ pmne o m epa men manage a me o e m na on. a u e o e u n ems o equ pmen esu n a ue o ems o be hh om na pa che o acc ue ea e."


jereme.guenther@gmail.com
jereme.guenther@gmail.com
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1493 Visits: 194
I'm sorry Colin, but I can't duplicate your problem. Using my code with the addin I gave you I was able to successfully print your problem code in italics with no missing letters. I would guess that you have made some other modification to the program to cause this.
Colin Hobby
Colin Hobby
Valued Member
Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)

Group: General Forum Members
Points: 58 Visits: 3

Jereme, the only mod I made to your code is to add the Italics in the chekbold function,

hereis what i changed, let me know if this is what you had intended:

For varPlace = 1 To varString.Length

If Mid(varString, varPlace, 3) = "<B>" Then

printStyle = FontStyle.Bold

varPlace += 2

ElseIf Mid(varString, varPlace, 4) = "</B>" Then

printStyle = FontStyle.Regular

varPlace += 3

ElseIf Mid(varString, varPlace, 4) = "<ST=" Then

varStartPlace = CInt(Mid(varString, varPlace + 4, _

InStr(varPlace + 4, varString, ">") - (varPlace + 4)))

varPlace += 4 + varStartPlace.ToString.Length

ElseIf Mid(varString, varPlace, 3) = "<I>" Then

printStyle = FontStyle.Italic

varPlace += 2

ElseIf Mid(varString, varPlace, 4) = "</I>" Then

printStyle = FontStyle.Regular

varPlace += 3

Else

ReDim Preserve aryString(3, aryString.GetUpperBound(1) + 1)

aryString(0, aryString.GetUpperBound(1) - 1) = _

Mid(varString, varPlace, 1)

aryString(1, aryString.GetUpperBound(1) - 1) = printStyle

aryString(2, aryString.GetUpperBound(1) - 1) = _

varStartPlace

varStartPlace = -1

End If



Colin Hobby
Colin Hobby
Valued Member
Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)

Group: General Forum Members
Points: 58 Visits: 3

Never mind I figured it out, sort of.

I tried the code without the tahoma font, and it works fine. I looked in my fonts directory and there was a tahoma and a tahoma Bold, but no Tahoma Italics.


jereme.guenther@gmail.com
jereme.guenther@gmail.com
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1493 Visits: 194
Nice catch, I wouldn't have thought of that; but it makes perfect sense now that you mention it.
djtechwork
djtechwork
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 3
jereme,

How modify the layout margin (left, top)?
jereme.guenther@gmail.com
jereme.guenther@gmail.com
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1493 Visits: 194
I'm not in a position to be able to test this at the moment, i'm deployed to Afghanistan, but I believe you can manipulate this line to increase the left hand margin:

Dim xmin As Integer = e.MarginBounds.Left


djtechwork
djtechwork
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 3
Jereme Guenther (11/30/2011)
I'm not in a position to be able to test this at the moment, i'm deployed to Afghanistan, but I believe you can manipulate this line to increase the left hand margin:

Dim xmin As Integer = e.MarginBounds.Left



Thanks for reply...

I've modified it using 'e.MarginBounds.Left / 100' to put left margin to 0 and <ST=...>

One more question..

When I decrease the font size, the space between 'vbCrLf' s doesn't dynamically change. I means the smaller the font size the greater the space between 'vbCrLf' s.

Could you give me clue how to manipulate the code to make the spaces change dynamically to fit the font size?

thanks....
jereme.guenther@gmail.com
jereme.guenther@gmail.com
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1493 Visits: 194
There are two different areas:

If you want to adjust the height of actual places try this line:
ymin += CInt(the_font.Height)



If you want to adjust the height of actual lines of text.
layout_rect = New RectangleF(xmin, ymin, e.MarginBounds.Right - xmin, the_font.Height)


and
If layout_rect.Height < 1 Then layout_rect.Height = 1


FlaCop
FlaCop
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 2
If I may, you can add the following lines to allow the user to select any printer using the print dialog in vb.net. Thanks for the coding, by the way.

' provide the user a dialog with which to choose his weapon!
Dim sysPrinter As New PrintDialog()
sysPrinter.ShowDialog()
Dim myprinter As Object = sysPrinter.PrinterSettings.PrinterName 'carry over the user's choices

' Create object, passing in text
Dim MyPrintObject As New TextPrint(docDocument)
' Set font, defaults to times new roman, 12 if omitted
MyPrintObject.Font = New Font("Arial", 11)

MyPrintObject.DefaultPageSettings.PrinterSettings.PrinterName = myprinter 'effect the change from default printer to your choice

' Issue print command
MyPrintObject.Print()

That does it! The use of "docDocument" was a sub that created the formatted document from raw text before sending to the printer.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search