 |
|
 |
Is there a way to specify some options of a printer?
Thanks.
email:zhangzq71@hotmail.com
|
|
|
|
 |
|
 |
Hi zhangzq71,
There are two ways to add printer-options.
1) in the control file - read the RFC link for details.
2) in the PostScript / PCL code, but these are not trivial to inject in the datastream. You have to check the manual of the printer for the details what options are possible.
Additional, you could extend the options in the controlfile with proprietary settings and let the receiving server handle these settings (You must use your own proprietary server then too of course)
What printer are you using?
Hopes this helps,
Rob
// 64 bit is still on my todolist ...
|
|
|
|
 |
|
|
 |
|
 |
Hi ZhangZQ,
Setting such options is outside the scope of LPR. The output of lpoptions you showed is related to the IPP protocol which is far more mature than LPR. I expect that at least in the linux world there is an open source IPP implementation you might find useful.
Nevertheless this is what I would do when you stick to LPR.
Use the XDC printerdriver and make a print with the settings you want and select print to file as option. You should be able to see how the XDC encodes the different settings into the postscript or as a specific header that prepended to the printfile. E.g. HP printers uses this for some PJL commands.
Hope this helps,
Rob
|
|
|
|
 |
|
 |
Rob,
Thank you very much for your information. I will try to get the solution by your hint.
Regards,
ZhangZQ
email:zhangzq71@hotmail.com
|
|
|
|
 |
|
 |
Has anyone had any luck getting this to work with Windows 7 Pro 64 bit? I have LPD and LPR support installed. I integrated this into my application and when I print from a Windows XP machine it works fine. If I use the Windows 7 machine the "Data" light on the Zebra printer will flash showing it received data but nothing will print.
|
|
|
|
 |
|
 |
Just to let you know I saw your msg,
I'm very bizzy right now and as soon as time permits I will have a look. Might take some weeks, sorry. Not used this code under win7/64 myself yet.
Rob.
Update 2011-08-09
A first quick look: it might be a problem with the IP address (IPV6 interference?)
modified on Tuesday, August 9, 2011 4:43 PM
|
|
|
|
 |
|
 |
Dear Rob,,, I am Developing IPhone App need to communicate from IPhone to Windows Server.(Eg. Print from IPhone to Windows Server). Is there any way to get the same Interface as i seen Your LPR Client int C#? If Possible can you reply my personal Email? Thanks & waiting for your kind reply....
|
|
|
|
 |
|
 |
Hi Murugan.mcse,
I like the idea of an LPR client for Iphone. It is on my wishlist for Android too, just for printing flat ASCII and PDF's mainly.
What do you mean by "the same interface"
1) the user interface around the LPR class?
2) the interface of the (C#) LPR class?
3) the interface on socket level?
add 1)
C# GUI's can't be ported to Iphones as far as I know. You need to redraw it with the Iphone IDE tools of your choice. That said, take into account that this app is landscape only and your mobile app should support portrait too. So you could follow the square design philosophy, to make this part easier.
add 2)
The code is free to use for anyone, but please make a reference (inspired by) to this article/source
add 3)
The LPR socket commands are well documented in - the RFC 1179[^]
Regards,
Rob
|
|
|
|
 |
|
 |
Dear Rob,,, Thanks for your Reply... From MAC Operating System using Line Printer Daemon protocol (LPD) we can able to Print.Simple Configuration ( Using LPD protocol & Windows Server IP or Host Address & The Print Queue Name & The Printer Driver Model)we can communicate from windows to Mac OS. I mean from Windows Print Server Using LPR we can able to Communicate our printers.The same way can able to write a program for IPhone using C#? Regards, MGN..
|
|
|
|
 |
|
 |
Murugan.mcse wrote: The same way can able to write a program for IPhone using C#?
No the Iphone cannot be programmed in C# AFAIK (As Far As I Know). But you can reuse the programlogic as shown in the LPR class to rebuild it on the Iphone platform.
Regards,
Rob
|
|
|
|
 |
|
 |
Rob,
I have an environment here where windows clients print via lpr to a windows server. The queue on the windows server is setup using the generic text driver, and I have print services for unix installed for the lpd service. The queue on this server is nothing more than a re-direct to a queue on an AIX machine (the windows server is just nice for authentication, and easier to setup the lpd.hosts file for just the one print server than for every user machine). I had previously just used the lpr.exe binary to send the file, and found that I had to specify the option: '-o l', which lpr /? (winxp) describes as:
-o option Indicates type of the file (by default assumes a text file)
Use "-o l" for binary (e.g. postscript) files
Compatibility with SunOS 4.1.x and prior
If I don't specify that option, the result spool file in lpd has carriage returns added (somewhat similar to ascii mode in ftp). After some packet snooping, it appears that the -o l option in lpr changes the control file output to be an l instead of an f - e.g. instead of fdfA040PC1, it sends ldfA040PC1 (like binary mode in ftp).
As such, I found that changing this line (~350 - just after getting the job id):
controlfile = String.Format("H{0}\nP{1}\nf{2}\nU{3}\nN{4}\n",
localhost, puser, dname, dname, Path.GetFileName(fname));
to this (bSendFileAsBinary being a bool, set to true):
controlfile = String.Format("H{0}\nP{1}\n{5}{2}\nU{3}\nN{4}\n",
localhost, puser, dname, dname, Path.GetFileName(fname), bSendFilesAsBinary ? "l" : "f");
sends my file as expected.
I'm not sure if anybody else has had this problem, but it resolves my issues here.
|
|
|
|
 |
|
 |
Hi Justin,
Good addition to the code, thanx. The CR/LF translation is probably done on the AIX printserver. If you dive into the manual of the AIX LPD you will probably find a configuration item that handles the CR/LF translation for the default (f - filter) so you might solve the issue there too. If that is a better solution depends on the needs of the other clients using this AIX printserver. Think I prefer your solution as it keeps the server in its default behavior.
some background
The original BSD (and later SunOS) LPR used the first letter of the name of the control-file to define which filter the LPD-daemon calls when spooling the file. These filters were configured in a plain textfile /etc/printcap It is a very easy mechanism to capture printstreams to do accounting, (re)scheduling jobs or translate LF => CRLF.
http://compute.cnr.berkeley.edu/cgi-bin/man-cgi?lpr[^]
Regards,
Rob
|
|
|
|
 |
|
 |
Hi Rob,
can you help way to insert PCL into datafile ? ( Ex: PCL HP).
Thank,
Hung
|
|
|
|
 |
|
|
 |
|
 |
I was finding that in a high-performance scenario that there were a couple of bottlenecks (that in reality probably wouldn't be a problem). To work around these, I'd suggest people protect the NetworkStream in SendFile() with a using {...} block.
In the interests of requesting the minimum access on a file, I'd also suggest changing to use a FileStream constructor, and explicitly requesting only read access, for example:
FileStream fstream = new FileStream(fname, FileMode.Open, FileAccess.Read, FileShare.Read);
|
|
|
|
 |
|
 |
(very late but) Thanx, good tips
Rob
|
|
|
|
 |
|
 |
I've reimplemented GetJobId() to give separate incrementing counts based on the user name, which some people may find useful, should they need to work in a service type environment:
private static Dictionary<string, int> LastJobId = new Dictionary<string, int>();
private int GetJobId()
{
int cnt = 0;
lock (LastJobId)
{
if( LastJobId.ContainsKey(puser) )
{
cnt = LastJobId[puser];
}
cnt++; cnt %= 1000;
if( LastJobId.ContainsKey(puser) )
{
LastJobId[puser] = cnt;
}
else
{
LastJobId.Add(puser, cnt);
}
}
return cnt;
}
|
|
|
|
 |
|
 |
Hi,
I am great Fan you, you are great ....
many & many thanks to you giving this code...
When I tried to print 100 jobs at a time,Iam getting the following error:
"A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 192.168.40.50:515 "
here 192.168.40.50 is my print server & port is 515.
Please help me to come out of this problem
PLease..please help me...& guide to solve this problem
Thanks
modified on Sunday, October 11, 2009 9:08 AM
|
|
|
|
 |
|
 |
Hi Balu,
Depending on the operating system you use (especially at the receiving end) there is a different maximum of the number of open sockets. WinXP differs from XP Pro, etc. Google for the details.
1. What OS are you using to send the jobs?
2. What OS (device) is receiving the jobs?
3. Is the error 100% repeatable?
4. Did you try other "batch" sizes e.g. 10 25 50 instead of 100?
5. Does it give the same error?
regards, rob
|
|
|
|
 |
|
 |
Hi Rob,
Once Again I am very & very thankfull to you for replying towards my question...
Thanks sir....
Please find below answers ..,
1. What OS are you using to send the jobs?
ans) windows XP professional
2. What OS (device) is receiving the jobs?
ans) printserver is windows 2003 server
Printer is Fujixerox MFD(apoes model)
3. Is the error 100% repeatable?
ans)yes it is 100% repeatable
4. Did you try other "batch" sizes e.g. 10 25 50 instead of 100?
ans)yes for everything greater than 10 jobs has the same problem
5. Does it give the same error?
ans) yes
To my knowledge LPR will use 515 port...,so once 10 jobs were sent to LPR,then 515 is not ready to accept the new job...so it failed by giving the above error.
One way to solve this problem is,if there more than 10 jobs then i have to wait until one of them in first ten to be completed and then accomidate next job to lpr..like wise for all of them in batch...
but Iam not able to do this & Iam exactly using your code,no changes were made to it....please help me & throw me out of this problem
Thanks & regards
Balu
|
|
|
|
 |
|
 |
balu12345 wrote: Hi Rob,
To my knowledge LPR will use 515 port...,so once 10 jobs were sent to LPR,then 515 is not ready to accept the new job...so it failed by giving the above error.
One way to solve this problem is,if there more than 10 jobs then i have to wait until one of them in first ten to be completed and then accomidate next job to lpr..like wise for all of them in batch...
but Iam not able to do this & Iam exactly using your code,no changes were made to it....please help me & throw me out of this problem
Thanks & regards
Balu
Hi Balu,
Indeed LPR uses port 515 by default, the LPD service of win2003 seems not to be able to have more than 10 listening sockets open, so the problem is not caused by the LPR code. To confirm this please try the following:
1. send more than 10 jobs directly to the printer
Does it accept all jobs? or same error?
My expectation: it will accept all jobs.
2. send more than 10 jobs directly to the another (LINUX, no windows) printserver.
Does it accept all jobs? or same error?
My expectation: it will accept all jobs.
I recall there are differences between OS-es in the area of nr of open sockets. The behaviour of the printserver can be (partly) configured in the registry. Please check the following link with plenty information:
http://technet.microsoft.com/en-us/library/cc778201(WS.10).aspx[^]
(note there are many more sites with printserver info)
I don't have the time to investigate which setting to change but carefull reading might help you. Please note that fiddling in the registry is at your own risk and not for the faint of heart. Please backup your registry before changing anything.
Regards,
Rob
|
|
|
|
 |
|
 |
Hi Rob,
I just recovered from fever so today only i have seen your reply
very & very thanks for your help....
you are right,when i send more than 10 prints drictly..then all of them were printed successfully.
why the same(batch printting) was not happening from code?plz share ur thoughts with me..
can plz help me for the following...
1.How to know/get acknowledgement that after LPR the job is printed successfully(i.e.,all its pages in that particular job is physically printed successfully)?if u have any code snippet please share it to me.
if I get above information..,then i will use thread mechanism to resolve the my actual LPR issue(failed after 10 jobs).
Thanks
|
|
|
|
 |
|
 |
Hi,
"Remote diagnostics is a wonderful game".
My conclusion so far is that there is a restriction in the printserver as told earlier. It is not simple to ask if physical pages are printed, you need a printer that supports e.g. SNMP and the printerMIB. But than again you need to know how many pages the jobs have to make an ideal solution.
An easier although a bit unreliable is to use an LPQ call and see if a particular job is still in the queue at the server. If theserver says that the job is not in the queue you may assume it is sent to the printer. That does not mean it is printed but probably it is busy printing.
The solution above is called "active polling" and is resource intensive (CPU, network, client & server) but it will not generate a large load if you put a sleep() in it.
You can implement this in several ways. Straightforward:
1. Send a job,
2. sleep some time and lpq the server until queue is empty
3. goto 1.
A more intelligent solution uses some system knowledge. Just send jobs and do an lpq to see #jobs in the queue at the server. If this is 10 (make that configurable) sleep for one second (also configurable). When the queuesize is less than 10 start sending jobs again. IN short use the fact that the server can buffer X jobs. The sleep time should be configurable as you only need to check after a page is printed, this minimizes the polling overhead. If the printer is 10PPM you only need to check every 6 seconds in theory. In practice I would check once a second.
Please note the above solutions are not foolproof, especially if there are multiple clients the straightforward solution can create starvation in theory. If this happens you need at least a faster printer
Hopes this helps enough to solve your problem
Regards, Rob
|
|
|
|
 |
|
 |
Hi Rob,
Iam very much thankfull to you...
I have implemented LPQ as per your suggestion and now iam able to print many number of jobs at a time without fail...
Thanks alot ....
thanks alot...
i need one more help from you... suppose my printer queuename is "Hp sample Queue" and Printer server IP "173.xxx.xx.xx"
LPQ is failed because my Queuename "Hp sample Queue" has white space in between it.
If it doesn't have white space(like "HpsampleQueue123")then it returned successfully
Please let me know how to make LPQ suuccessfull even if Printer Queue name("Hp sample Queue") has white spaces in between it? and even how to handle it in c# code?
Please help me sir...
Iam very & very much thankfull for you
Thanks
|
|
|
|
 |