Originally posted by: Frederick
How would you write a script that capture a specific printer tray (e.g. 2) and prints the open document?
ps: The rpinter is a networked printer
Thanks
Originally posted by: sanpee
Just wonder if anyone faced this before. The code seems to work find at first. After I install a printer driver that uses LPT1, things get weird. I found that LPT1 is taking over by Spooler Manager, anything you you send to LPT1 will be intercept by Spooler Manager. It is ok for many applications, but not for my case. I actually use this to auto detect whether there is a good connection to the printer. I know the advice to use a parallel port driver, but somehow that is not allowable, and it's running on Win2K. Would appreciate if someone can show me a way to bypass Spooler Manager.
ReplyOriginally posted by: Kevin Clancy
It's great to hear that there's a way you can print in MFC Dialog apps without using rocket science, but whenever I try it, my printer makes a chirp noise, like it's about to print, but it doesn't do anything.
Reply
Originally posted by: Mark Lakata
http://www.dragon-it.co.uk/links/hp_pcl_codes.htm
I've used this without any problems.
Also, you should send a Form Feed character at the end of the print job, otherwise you will have to push the page advance button to eject the page. Form Feed = ^L = 0x014 = dec(12)
it works for me...
-Mark
This is really regressing 10 years in technology, but if
you know the printer understands HP PCL, then you can
send the old fashioned DOS-link escape sequences. This will let you change the font width and the line height.
Reply
Originally posted by: Maria Farrington
We have the following net use command set up:
net use lpt1 \\server\printername /persistent:yes
Our application only allows us to select lpt1 as the output device, which works fine, but it always defaults to the #2 default paper tray. We would like the output to pull from the #3 tray.
Is there a switch that can be used with the line command above to send it to a different tray.
Any help is much appreciated.
Thanks, Maria
Originally posted by: Raymond Yiu
Hi,
I tried the code in win98. However, it does not work. And the app just keep going thinking that the printer is online.
I did not plug in the printer yet. Does it make a different?
I use fprint and fflush to do the print (lineprinting)... and the printer folder does not even have the job displayed as printing. (ie. no job in the printer folder).
However, I ran the same program on NT, everything works. (I did not use the _inp for NT) but the spooling will pick up the error if the fflush cannot flush to the printer.
Thanks in advance.
Raymond.
Reply
Originally posted by: Mark
WritePrinter( hPrinter,temp,strlen(temp), &dwBytesWritten );
I created a VB program that sends raw data to the printspooler.
It works fine in both Win2k and Win98.
I translate that to c and it does not work in Win2k
Here is the VB code:
lReturn = OpenPrinter(List1.Text, lhPrinter, 0)
If lReturn = 0 Then
Exit Sub
End If
Set Fs = New FileSystemObject
MyDocInfo.pDocName = fname
MyDocInfo.pOutputFile = vbNullString
MyDocInfo.pDatatype = vbNullString
For x = 1 To Val(List2.Text)
Set FF = Fs.OpenTextFile(fname)
lDoc = StartDocPrinter(lhPrinter, 1, MyDocInfo)
'Call StartPagePrinter(lhPrinter)
Do While Not FF.AtEndOfStream
temp = FF.Read(BUFF_SIZE)
If Len(temp) > 0 Then
lReturn = WritePrinter(lhPrinter, ByVal temp, Len(temp), lpcWritten)
Else
Exit Do
End If
temp = ""
Loop
FF.Close
'lReturn = EndPagePrinter(lhPrinter)
lReturn = EndDocPrinter(lhPrinter)
Sleep 500
Next
lReturn = ClosePrinter(lhPrinter)
--------------------------------------------------
Here is the C code:
if(GetOpenFileName(&OpenFileName))
{
// OpenFileName section not shown
MyDocInfo.pDocName=(char*)fname;
MyDocInfo.pOutputFile=NULL;
MyDocInfo.pDatatype=NULL;
lReturn=OpenPrinter(prname,&hPrinter,(LPPRINTER_DEFAULTS)NULL);
index=ListBox_GetCurSel(Copieslist);
ListBox_GetText(Copieslist,index,sCopies);
nCopies=VAL(sCopies);
FF=fopen(fname,"rb");
if(!FF)
{
sprintf(msg,"Can't open %s",fname);
MessageBox(NULL,msg,"Error",MB_ICONERROR);
return;
}
//
for(x=1;x<=nCopies;x++)
{
if(!StartDocPrinter(hPrinter,1,(LPBYTE)&MyDocInfo))
{
MessageBox(NULL,"StartDocPrinter failed","Error",MB_ICONERROR);
break;
}
StartPagePrinter(hPrinter);
while(!feof(FF))
{
if(!fread((void*)temp,BUF_SIZE,1,FF))
break;
memset((void*)temp,0,BUF_SIZE);
}
fseek(FF,0,0);
// lReturn = EndPagePrinter(hPrinter)
lReturn=EndDocPrinter(hPrinter);
Sleep(500);
}
fclose(FF);
lReturn=ClosePrinter(hPrinter);
}
------
After extensive troubleshooting, I found everything is working except the actual printing under Win2k.Works fine under Win98.
What am I doing wrong?
Originally posted by: kishore
I am generating spool file output & then give printing comand from shell, but this creates session which doesn't get killed and it shows "winoldap" in taskbar. If I give printing command five times, it create "Winoldap" in taskbar. How to solve this problem..
Reply
Originally posted by: jarrod
I used the code that was printed in the main article here, but it seems that Dick either forgot to mention or purposely left out the rest of the real world application for this code. I need this code so I can print data out to a reciept tape printer. He mentioned something about registry entries for opening the LPT1 port refered to in the code. If anyone knows how to do this, please email it to me, with a "real world application" that works. It would be greatly appreciated...THANK YOU!
jarrod
ReplyOriginally posted by: Ray
I'm sending a series of text files (~400 byte CStrings) to LPT1. This chunk of code that works fine under Win98 without the do loop and works under NT with the do loop. Is there anyway to monitor the return values from the parallel port using Readfile? I really don't want to use the View class or write a device driver to do this.
for (int i = 0; i < p_qty; i++)
Hello,
{
pars_buf.Empty();
pars_buf += sn_head;
pars_buf += snNums.GetAt(i);
pars_buf += sn_tail;;
len = pars_buf.GetLength();
do
hFile = CreateFile("LPT1", GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS FILE_ATTRIBUTE_NORMAL NULL);
while (hFile == INVALID_HANDLE_VALUE);
if(WriteFile(hFile, pars_buf, len, &nBytes, NULL))
CloseHandle(hFile);
}