Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««1234

Printing in .NET Expand / Collapse
Author
Message
Posted Wednesday, November 15, 2006 2:22 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, November 23, 2010 4:07 PM
Points: 10, 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."

 

Post #323265
Posted Wednesday, November 15, 2006 5:06 PM
Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Wednesday, February 05, 2014 8:30 AM
Points: 769, Visits: 191
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.
Post #323301
Posted Thursday, November 16, 2006 10:57 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, November 23, 2010 4:07 PM
Points: 10, 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:

</P><FONT color=#0000ff size=2><P>For</FONT><FONT size=2> varPlace = 1 </FONT><FONT color=#0000ff size=2>To</FONT><FONT size=2> varString.Length</P><P></FONT><FONT color=#0000ff size=2>If</FONT><FONT size=2> Mid(varString, varPlace, 3) = "&lt;B&gt;" </FONT><FONT color=#0000ff size=2>Then</P></FONT><FONT size=2><P>printStyle = FontStyle.Bold</P><P>varPlace += 2</P><P></FONT><FONT color=#0000ff size=2>ElseIf</FONT><FONT size=2> Mid(varString, varPlace, 4) = "&lt;/B&gt;" </FONT><FONT color=#0000ff size=2>Then</P></FONT><FONT size=2><P>printStyle = FontStyle.Regular</P><P>varPlace += 3</P><P></FONT><FONT color=#0000ff size=2>ElseIf</FONT><FONT size=2> Mid(varString, varPlace, 4) = "&lt;ST=" </FONT><FONT color=#0000ff size=2>Then</P></FONT><FONT size=2><P>varStartPlace = </FONT><FONT color=#0000ff size=2>CInt</FONT><FONT size=2>(Mid(varString, varPlace + 4, _</P><P>InStr(varPlace + 4, varString, "&gt;") - (varPlace + 4)))</P><P>varPlace += 4 + varStartPlace.ToString.Length</P><P></FONT><FONT color=#0000ff size=2>ElseIf</FONT><FONT size=2> Mid(varString, varPlace, 3) = "&lt;I&gt;" </FONT><FONT color=#0000ff size=2>Then</P></FONT><FONT size=2><P>printStyle = FontStyle.Italic</P><P>varPlace += 2</P><P></FONT><FONT color=#0000ff size=2>ElseIf</FONT><FONT size=2> Mid(varString, varPlace, 4) = "&lt;/I&gt;" </FONT><FONT color=#0000ff size=2>Then</P></FONT><FONT size=2><P>printStyle = FontStyle.Regular</P><P>varPlace += 3</P><P></FONT><FONT color=#0000ff size=2>Else</P></FONT><FONT size=2><P></FONT><FONT color=#0000ff size=2>ReDim</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Preserve</FONT><FONT size=2> aryString(3, aryString.GetUpperBound(1) + 1)</P><P>aryString(0, aryString.GetUpperBound(1) - 1) = _</P><P>Mid(varString, varPlace, 1)</P><P>aryString(1, aryString.GetUpperBound(1) - 1) = printStyle</P><P>aryString(2, aryString.GetUpperBound(1) - 1) = _</P><P>varStartPlace</P><P>varStartPlace = -1</P><P></FONT><FONT color=#0000ff size=2>End</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>If</P><P></FONT>&nbsp;

Post #323560
Posted Thursday, November 16, 2006 11:12 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, November 23, 2010 4:07 PM
Points: 10, 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.  

Post #323567
Posted Thursday, November 16, 2006 11:35 AM
Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Wednesday, February 05, 2014 8:30 AM
Points: 769, Visits: 191
Nice catch, I wouldn't have thought of that; but it makes perfect sense now that you mention it.
Post #323573
Posted Wednesday, November 30, 2011 3:49 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Saturday, December 03, 2011 9:15 AM
Points: 2, Visits: 3
jereme,

How modify the layout margin (left, top)?
Post #1213788
Posted Wednesday, November 30, 2011 6:59 PM
Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Wednesday, February 05, 2014 8:30 AM
Points: 769, Visits: 191
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

Post #1214323
Posted Saturday, December 03, 2011 7:12 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Saturday, December 03, 2011 9:15 AM
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....
Post #1215841
Posted Saturday, December 03, 2011 10:13 AM
Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Wednesday, February 05, 2014 8:30 AM
Points: 769, Visits: 191
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 &lt; 1 Then layout_rect.Height = 1

Post #1215868
Posted Tuesday, December 25, 2012 5:31 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, December 25, 2012 5:25 PM
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.
Post #1400107
« Prev Topic | Next Topic »

Add to briefcase «««1234

Permissions Expand / Collapse