printing on network printer

Discussion in 'ASP .Net' started by Maileen, Jul 7, 2004.

  1. Maileen

    Maileen Guest

    Hi,

    I want to print from my ASP page directly to my network printer. For this i
    use the following code, but everytime, my document to print is sent to local
    and physical port LPT1 :(
    could you help me please ? thx,
    Maileen.

    '---- to print report on network printer ---
    ' RSP = stored procedure
    Set objFS = CreateObject("Scripting.FileSystemObject")
    Set objWSHNet = CreateObject("WScript.Network")
    if trim(RSP("p_login"))<>"" then
    login=""&trim(RSP("p_login"))&""
    heslo=""&trim(RSP("p_heslo"))&""
    objWSHNet.AddPrinterConnection "LPT1:", trim(RSP("cesta")), False,login,
    heslo
    else
    objWSHNet.AddPrinterConnection "LPT1:", trim(RSP("cesta")), False
    end if
    Set objPrinter = objFS.CreateTextFile("LPT1:", True)
    ....
    objPrinter.Write("simple printing test")
    objPrinter.Close
    '---------------------------------------------------
    Maileen, Jul 7, 2004
    #1
    1. Advertising

  2. Maileen

    Stu Lock Guest

    Hi,

    Looks like you are using the old objects to print. Try using the new print
    classes from .Net to enumerate the printers installed on the machine running
    the code:

    If System.Drawing.Printing.PrinterSettings.InstalledPrinters.Count > 0 Then
    'Printers installed....
    Else
    'No printers installed
    End If

    Hope this points you in the right direction.

    Stu


    "Maileen" <> wrote in message
    news:...
    > Hi,
    >
    > I want to print from my ASP page directly to my network printer. For this
    > i
    > use the following code, but everytime, my document to print is sent to
    > local
    > and physical port LPT1 :(
    > could you help me please ? thx,
    > Maileen.
    >
    > '---- to print report on network printer ---
    > ' RSP = stored procedure
    > Set objFS = CreateObject("Scripting.FileSystemObject")
    > Set objWSHNet = CreateObject("WScript.Network")
    > if trim(RSP("p_login"))<>"" then
    > login=""&trim(RSP("p_login"))&""
    > heslo=""&trim(RSP("p_heslo"))&""
    > objWSHNet.AddPrinterConnection "LPT1:", trim(RSP("cesta")), False,login,
    > heslo
    > else
    > objWSHNet.AddPrinterConnection "LPT1:", trim(RSP("cesta")), False
    > end if
    > Set objPrinter = objFS.CreateTextFile("LPT1:", True)
    > ...
    > objPrinter.Write("simple printing test")
    > objPrinter.Close
    > '---------------------------------------------------
    >
    >
    >
    Stu Lock, Jul 7, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Amrendra Nath
    Replies:
    1
    Views:
    2,426
    Natty Gur
    Oct 21, 2003
  2. Samuel Lee
    Replies:
    0
    Views:
    498
    Samuel Lee
    Nov 11, 2003
  3. Thomas Feuerstack
    Replies:
    1
    Views:
    857
    Thomas Weidenfeller
    Dec 14, 2005
  4. Maravilloso
    Replies:
    0
    Views:
    303
    Maravilloso
    Oct 26, 2005
  5. Replies:
    0
    Views:
    377
Loading...

Share This Page