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 Tuesday, January 31, 2006 9:47 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 5, 2014 8:30 AM
Points: 769, Visits: 191
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/jGuenther/printinginnet.asp
Post #254843
Posted Wednesday, February 1, 2006 11:43 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 5, 2014 8:30 AM
Points: 769, Visits: 191
I have noticed a major flaw in this code.  It prints great when using the Tahoma font, but anything else seems to really mess it up.
Post #255033
Posted Wednesday, February 1, 2006 2:27 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 5, 2014 8:30 AM
Points: 769, Visits: 191

Ok, I have found the problem.  Apparently Microsoft has a bug in their e.Graphics.MeasureString function.  To remidy this re-organize the primary if block like this:

If Asc(smallArray(0, x).Chars(0)) < 30 Then ' make sure to dispose of odd char's in the array

' See if any characters will fit.

ElseIf characters_fitted > 0 And xmin < (e.MarginBounds.Right - 5) Then

Notice that I switched the if and elseif lines, that is because I was occasionally printing out a graphical representation for the char(0).

Post #255081
Posted Wednesday, February 1, 2006 3:16 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 5, 2014 8:30 AM
Points: 769, Visits: 191

Another update, I have perfected the variable character spacing problem when the font size and type changed.  Add the following line somewhere above The 'Static i As Integer' line:

' Prepare the fixed spacing for each character
Dim fixedSpace As SizeF = e.Graphics.MeasureString("W", the_font)

Then replace the following line:
' Increase the location where we can start.
xmin += CInt(text_size.Width) - 4

with:
' Increase the location where we can start.
xmin += CInt(text_size.Width) - (fixedSpace.Width * 0.25)

Post #255098
Posted Wednesday, March 1, 2006 2:20 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Friday, November 21, 2014 7:42 AM
Points: 6,743, Visits: 8,515
Do you know of a simple way of making a screen-shot (winforms) with .Net code, using the framework (not extra referring to the gdi32.dll ) ?

Johan


Don't drive faster than your guardian angel can fly ...
but keeping both feet on the ground won't get you anywhere

- How to post Performance Problems
- How to post data/code to get the best help


- How to prevent a sore throat after hours of presenting ppt ?


"press F1 for solution", "press shift+F1 for urgent solution"


Need a bit of Powershell? How about this

Who am I ? Sometimes this is me but most of the time this is me
Post #262196
Posted Wednesday, March 1, 2006 2:53 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, April 7, 2011 9:14 PM
Points: 10, Visits: 22

Hi Jereme

Thanks for this nice piece of work!

I have tried to get it to work in ASP.NET 1.1 (vb) but get a run time error "No printers installed."

I do have a deault printer but it is a network printer and not on LPT1.

Any ideas?

Many Thanks

Howard Rybko

 

Post #262207
Posted Wednesday, March 1, 2006 12:08 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 5, 2014 8:30 AM
Points: 769, Visits: 191
 
Hi Howard, that is my fault for not giving you all the code to properly initialize the class.  Try the following:
 

       ' Create object, passing in text
        Dim MyPrintObject As New TextPrint("<B>this will be bold</B>" + vbCrLf + "<ST=400>this will start at 400 pixels", "MyPrinterName")

Also modify the printing class itself to accept two parameters:

' New constructor
Public Sub New(ByVal Text As String, ByVal pName As String)
  ' Sets the file stream
  MyBase.New()
  varStart = 0
  strText = Text
  MyBase.PrinterSettings.PrinterName = pName ' This is the key line for setting the printer
  MySplitLine = strText.Split(vbCrLf)
End Sub

I too use exclusively network printers not local LPT1 ports.

Post #262448
Posted Wednesday, March 1, 2006 12:19 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 5, 2014 8:30 AM
Points: 769, Visits: 191

Hi alzdba,

  I have never tried taking a screen shot in .net.  Here is a link on how to do it but I does appear that you will need to use API functions.

http://www.developerfusion.co.uk/show/4630/

Post #262451
Posted Wednesday, March 1, 2006 2:22 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, June 15, 2007 6:08 PM
Points: 6, Visits: 1
I've not tried your code, but I just want to say thank you for sharing your hardwork with everyone. It's very generous of you.
Post #262503
Posted Wednesday, March 1, 2006 7:02 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, August 4, 2009 2:56 PM
Points: 8, Visits: 12
Thanks for sharing.  It is very generous of you.


Post #262560
« Prev Topic | Next Topic »

Add to briefcase 1234»»»

Permissions Expand / Collapse