Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 535
  • Last Modified:

Dumping print data to a parallel port thermal printer for printing

Hi Experts,
I need urgent help on a problem i am facing.
I am developing an application that generates shipping  transactions using fedex webservices.The transactions are generated but it returns the shipping lablels having barcodes, address etc, & saves it  as a text file .I need to print these labels on a thermal printer (ZEBRA attached to LPT1 port).The saved text file seems to be a set of printer commands.
My problem is :
I need to send this file to the parallel port e.g.LPT1  which has a thermal printer on it, in order to print it programatically using VB.NET or VB. Can anyone help me ?

The partial contents of saved labels file  are as below:
^XA^CF,0,0,0^PR12^MD30^PW800^PON
^FO0,147^GB800,4,4^FS
^FO0,401^GB800,4,4^FS
^FO0,746^GB800,4,4^FS
^FO35,12^AdN,0,0^FWN^FH^FDFrom:^FS
^FO35,31^AdN,0,0^FWN^FH^FDRobert Climp^FS
^FO35,51^AdN,0,0^FWN^FH^FDMicro Corporation^FS
^FO35,71^AdN,0,0^FWN^FH^FD256 VIRGIN STREET^FS
^FO35,92^AdN,0,0^FWN^FH^FD^FS
^FO35,112^AdN,0,0^FWN^FH^FDMary Land, TX 77479^FS
^FO35,132^AdN,0,0^FWN^FH^FD(713)203-2500^FS
^FO490,31^AdN,0,0^FWN^FH^FDShip Date: 31MAR06^FS
0
calorisplanitia
Asked:
calorisplanitia
  • 5
  • 5
1 Solution
 
PockyMasterCommented:
You have some options, one of that it call a dos command to copy the content of your file to the LPT1 :D
That's the easiest,

another is use API's to create the printer connection and do it that way.
0
 
PockyMasterCommented:
I wasn't able to test it (have no printer on LPT1) but I guess it should work.

 Private Sub PrintFile(ByVal FileName As String)
        Dim si As New ProcessStartInfo()

        With si
            .FileName = System.Environment.GetEnvironmentVariable("COMSPEC")
            .Arguments = String.Format("/C print /D:LPT1 {0}", FileName)
            .UseShellExecute = False
            .CreateNoWindow = True

        End With

 Process.Start(si)

End Sub
0
 
calorisplanitiaAuthor Commented:
thanks for the promt reply
I will test it & let you know
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
calorisplanitiaAuthor Commented:
I have tried using the following but it doesnt do anything

PrintFile("c:/labels/label.txt")

Private Sub PrintFile(ByVal FileName As String)
        Dim si As New ProcessStartInfo()

        With si
            .FileName = System.Environment.GetEnvironmentVariable("COMSPEC")
            .Arguments = String.Format("/C print /D:LPT1 {0}", FileName)
            .UseShellExecute = False
            .CreateNoWindow = True

        End With

 Process.Start(si)

End Sub
0
 
PockyMasterCommented:
And if you type the command in a console in windows
print /D:LPT1 c:\labels\label.txt

does it print?
0
 
calorisplanitiaAuthor Commented:
the command promnt says
C:\labels\label.txt is currently being printed

but as iam running this through remote desktop on remote server i cannot actually see whether its really printing or not,but the printer que doesnt show anything or any file qued

maybe its printing, i need to check that

0
 
PockyMasterCommented:
if the printer is shared via network you also can try :
Copy c:\labels\label.txt \\WhatEverShare\YourPrinter

I used this one a couple of weeks ago (also on a Zebra printer)
0
 
calorisplanitiaAuthor Commented:
i think its working ....
things will be clear after i do some more tests
0
 
calorisplanitiaAuthor Commented:
thank you very much for the promt solution.
It works fine.
Problem solved!

Next thing is to develop it to work on asp.net webpage so that it print on server, which i think will work with you solution.
I have acceptyed your answer.
0
 
PockyMasterCommented:
Ok, Have fun!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now