.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Copy .plt files to a plotter

19 REPLIES 19
SOLVED
Reply
Message 1 of 20
GeeHaa
2169 Views, 19 Replies

Copy .plt files to a plotter

Hi

 

I'm trying to copy plot files to a plotter with filecopy(plotfile,\\server\plottername) it works fine when I have the UNC address but there are network printers without this address that I need to copy files too. I have the IP addresses of these printers.Is there a way to send a file to an IP address?

 

Thanks in advance

19 REPLIES 19
Message 2 of 20
fieldguy
in reply to: GeeHaa

I have used FTP to do this with several HP devices.  I think all hp printers support ftp.  You can test it from the dos prompt with the following 6 lines:

ftp <enter>

open printer.ip.address  
<login> user
<pword> guest
put "your printfile"

quit

If that works, you can code an ftp transfer using the system.net namespace.  Post back if you want an example.

Message 3 of 20
GeeHaa
in reply to: fieldguy

Thanks very much for the response.

 

It lets me login but when I use the put command It gives me .550  the system cannot find the specified file.

 

Im using  Put C:\lisp\X.plt   I tried it with quotes also. But I would like to see the code.

 

Thanks

Message 4 of 20
fieldguy
in reply to: GeeHaa

OK.  I will post it in the morning - miller time now.

Try the script from the same folder (c:\lisp) with put "x.plt".

Message 5 of 20
SENL1362
in reply to: GeeHaa

This might help you

 

From within DOS command:

net use LPT1 \\PrinterIpAddress\lpr

copy /b C:\temp\xxx.prn LPT1

 

or

lpr -S PrinterIpAddress -P printer -o l  c:\temp\xxx.prn

 

 

Message 6 of 20
GeeHaa
in reply to: GeeHaa

I tried changing to the C:\lisp folder and using put "x.plt". Two lines come up, one says 200 Port command successful. The other says 550 The system cannot find the file specified . I tried using lpr but it comes up as an unrecognized command.

 

Thanks

Message 7 of 20
fieldguy
in reply to: GeeHaa

I am having trouble (error 550) coding the script.  In other words, I can manually ftp using open and put, but error 550 is persistent in .NET.  I checked my other app and it uploads TIF images to a KIP printer without issue but the same code will not work with my hp laser.

 

There are examples on the internet (http://www.vbforums.com/showthread.php?t=468649) but I do not have the time to figure out why I cannot get that to work.

 

I am leaning towards the "net use" suggestion from SENL1362.  I have used LPR before as well but can't remember where it came from.

 

Sorry!

 

 

Message 8 of 20
GeeHaa
in reply to: fieldguy

Oops the put command does work on HP plotters I was trying it on an Oce.

Message 9 of 20
SENL1362
in reply to: GeeHaa

using XP? changes are you did not install the Print Services for Unix.

Add Windows components/other network file and print services.

You'll need the i386 part of the xp installation disc.

 

 

Message 10 of 20
SENL1362
in reply to: GeeHaa

did you verify the ipadress of the printer ?

try

ping <ipadress>

or

telnet <ipadress>

 

You can log in on these oce printers if you have a root password

telnet XXXXXXX
Trying XXX.XXX.XXX.XXX...
Connected to XXX.XXX.XXX.XXX.
Escape character is '^]'.

Network Printer Server Version 5.6.3 (XXX.XXX.XXX.XXX)

login: root
Password: <root pw here>

Welcome root user

XXX.XXX.XXX.XXX:root> list sysinfo

 

 

Message 11 of 20
GeeHaa
in reply to: GeeHaa

When I use the open IP address command it opens the right plotter. Ping also works. The telnet command is unrecognized. I tried the code from the link and I still get the 550 file not found error. It says its logged in and everything in the response section of the error status. According to the OCe users manual FTP should work.

 

Sub TEST()
        Dim clsRequest As System.Net.FtpWebRequest = _
        DirectCast(System.Net.WebRequest.Create("ftp://serv/oce tds750/X.plt"), System.Net.FtpWebRequest)
        clsRequest.Credentials = New System.Net.NetworkCredential("anonymous", "Password")
        clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile

        ' read in file...
        Dim bFile() As Byte = System.IO.File.ReadAllBytes("C:\Lisp\X.plt")

        ' upload file...
          Dim clsStream As System.IO.Stream = _
                        clsRequest.GetRequestStream()
            clsStream.Write(bFile, 0, bFile.Length)
            clsStream.Close()
            clsStream.Dispose()
             
    End Sub

 

Thanks

 

Message 12 of 20
SENL1362
in reply to: GeeHaa

Ok, it's a OCE 750, probably HPGL2  contents to upload.

This requires binary mode because of the non ASCII data.

 

That's why i mentioned copy /b 

see this VB .net 2 sample 

http://www.codeproject.com/Articles/17202/Simple-FTP-demo-application-using-C-Net-2-0

 

Message 13 of 20
GeeHaa
in reply to: GeeHaa

I sort of figured out half of it. On the Oce after logging in and typing binary you have to change directories to the jobs folder on the plotter server. Once I did this the Put "x.plt" command worked now I just have to figure out how to change to this directory  in .Net.

 

Thanks for all your help.

Message 14 of 20
GeeHaa
in reply to: GeeHaa

Here Is what I'm trying. It pops up a command window and it sits open for about 30 seconds as if it was logging in but it does not print and it doesn't throw an exception maybe one of you can see what is wrong.

Dim pr As Process
        Dim args As New ProcessStartInfo("cmd.exe")
        With args
            .RedirectStandardInput = True
            .RedirectStandardOutput = True
            .UseShellExecute = False
            .WindowStyle = ProcessWindowStyle.Normal
        End With
        pr = Process.Start(args)
        pr.StandardInput.WriteLine("echo on" & Convert.ToChar(13)) 'chr(13) Enter key.
        pr.StandardInput.WriteLine("CD C:\LISP" & Convert.ToChar(13)) 'chr(13) Enter key.
        pr.StandardInput.WriteLine("FTP" & Convert.ToChar(13))
        pr.StandardInput.WriteLine("OPEN 192.1.1.164" & Convert.ToChar(13))
        pr.StandardInput.WriteLine("anonymous" & Convert.ToChar(13))
        pr.StandardInput.WriteLine(Password  & Convert.ToChar(13))
        pr.StandardInput.WriteLine("binary" & Convert.ToChar(13))
        pr.StandardInput.WriteLine("cd jobs" & Convert.ToChar(13))
        pr.StandardInput.WriteLine("put " + Chr(34) + "x x.plt" + Chr(34) & Convert.ToChar(13))
        pr.StandardInput.WriteLine("bye")
        pr.CloseMainWindow()

If I try this manually it works fine. 

Again thanks very much for your help.

Message 15 of 20
SENL1362
in reply to: GeeHaa

Isn't writeline already terminating the input with CR+LF

 

The enter key is CR+LF, so maybe you have to terminate each line with chr(13)+chr(10)

You did not terminate BYE

Message 16 of 20
GeeHaa
in reply to: GeeHaa

Adding the Line Feed after enter works. The only problem is it leaves the Dos window open and does not send the plots until you click inside the window and hit enter. I tried sending an enter and Line feed after bye but it still stays open without sending the files.

 

Thanks

Message 17 of 20
fieldguy
in reply to: fieldguy

I got the code to work for my hp laser.  GeeHaa's comment about the "jobs" folder on the printer got me thinking.

 

I used the same script as before but used "pwd" (print working directory).  The printer replied "/" is the current directory.  I added an extra slash to the URI in the code and it worked.

 

Test script from CMD:

ftp

open 192.168.1.1

<login> user

<pword> guest

pwd <enter>

quit

 

<CommandMethod("ftp4")> _
    Public Shared Sub ftp4()
        Dim request As FtpWebRequest = _
            DirectCast(FtpWebRequest.Create("ftp://192.168.1.1//" & Path.GetFileName("c:\Temp\TEST.TXT")), FtpWebRequest)
        request.Method = WebRequestMethods.Ftp.UploadFile
        request.Credentials = New NetworkCredential("user", "guest")
        request.UsePassive = False
        request.UseBinary = True
        request.KeepAlive = False
        request.Proxy = Nothing
        'request.r
        'Load the file
        Dim stream As FileStream = File.OpenRead("c:\Temp\test.txt")
        Dim buffer As Byte() = New Byte(CInt(stream.Length - 1)) {}
        stream.Read(buffer, 0, buffer.Length)
        stream.Close()
        'Upload file
        Dim reqStream As Stream = request.GetRequestStream()
        reqStream.Write(buffer, 0, buffer.Length)
        reqStream.Close()
        MsgBox("Uploaded Successfully", MsgBoxStyle.Information)
    End Sub

 

The code above can be used to upload plt files to hp printers. 

 

Message 18 of 20
SENL1362
in reply to: GeeHaa

Unfortunately currently i cannot do tests on any OCE device, but did some tests earlier.

One of tests had to do with the OCE JobTicket, the header info in a OCE PRN file.

Have a look at the the OCE JobTicket 2.6 specifications. One of the setings is JobStore:

JobStore boxname <dbname>
This specifies the name of the Smart Inbox in which the job shall be stored.

 

 

BeginTicket 2.6
  username JohnSmith
  jobname "TestJob 1"
  jobStore boxname myqueue
  BeginBlock 1
    hpgl2 plottertype HP650C origin lowerright  sp_eof off merge off
    Segment 1
    emulation hpgl2
  EndBlock

  BeginOutput
    includeBlock 1
  EndOutput
EndTicket
*OceJobData
      ESC%0BINBP5,1CO"Océ WPD - version 1.19 build 10.12.07.1"PS37200,11880IP0...
*OceJobEnd

 This type of PRN files can be submited to the OCE printer either

- using a simple copy command:copy /b C:\temp\oce.prn LPT1

- using youre ftp way of printing probably without the need to change the directory

 

 

Message 19 of 20
GeeHaa
in reply to: GeeHaa

DirectCast(FtpWebRequest.Create("ftp://192.168.1.1/jobs/" & Path.GetFileName("c:\Temp\TEST.TXT")), 

 Thank You both so much. All I did was add Jobs  in the URI and it Worked!!!

Message 20 of 20
GeeHaa
in reply to: GeeHaa

In order to send more than one file at a time (without logging in for each file) using this method do I need to use asynchronous operations?

 

Thanks

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost