I want to print a file which contains ascii characters by using
"asciifile.txt > LPT1:"
Here the LPT1 is mapped to an USB connected printer. When this command is
given, file is printed but the lines are printed as one line every 5-6 sec.
At the end of the file printing the paper is ejected out but the printer
seems to be still waiting for some more data which is indicated by blinking a
light on the printer.
Why is it taking so much time to print each line?
Is there any specific command that needs to be sent to the printer to
indicate end of printing?

Thanks & Regards,
-Rams

RE: Printing Ascii text by coreyb

coreyb
Mon Aug 01 21:05:22 CDT 2005

I'm not sure why printing in that method is slow, but you might want to try
writing a simple app that does the same thing and see if it too has
problems. The code would probably look a little like the following:

HDC hDC = NULL;
DOCINFO doc_info;
DWORD cxPage, cyPage, yChar, dwLinesPerPage, dwLine;

doc_info.cbSize = sizeof(doc_info);
doc_info.lpszDocName = _TEXT("asciifile.txt");

hDC = GetPrinterDC();
GetTextMetrics(hDC, &textMetrics);
cxPage = GetDeviceCaps(hDC, HORZRES);
cyPage = GetDeviceCaps(hDC, VERTRES);
yChar = textMetrics.tmHeight + textMetrics.tmExternalLeading;
dwLinesPerPage = cyPage / yChar;

StartDoc(hDC, &doc_info);
for(i = 0; i < dwPages; i++)
{
StartPage(hDC);
ReadFile(hFile, szBuffer, cbBufferSize - 1, &cbBytesRead, NULL);

// Convert ascii chars to UNICODE if necessary
#ifdef UNICODE
MultiByteToWideChar(CP_ACP, 0, szBuffer, cbBytesRead, tszPrintText,
#else
strncpy(tszPrintText, szBuffer, cbBytesRead);
#endif

for(dwLine = 0; dwLine < dwLinesPerPage; dwLine++)
{
TextOut(hDC, 0, (k * cyPage) + (yChar * dwLine), tszPrintText,
cbBytesRead);
}
EndPage(hDC);
}
EndDoc(hDC);
DeleteDC(hDC);


RE: Printing Ascii text by Rams

Rams
Tue Aug 02 01:45:03 CDT 2005

Hi Bruke,

Thanks for the info. I came to know the problem was with the
printer. It was printing because of the content of the file. It was able to
print properly with other data files. The new problem that I faced now was
that when I give a print command, the file is printed properly but after
ejecting the paper out of the prniter, the light of the printer is still
blinking indicating that it is expecting data. This will not blink before
giving the first print command after the printer is powered up. Let me know
what command needs to be sent to the printer to indicate that the printer
data is complete (like form feed is sent to eject out the paper completely
out of the printer). Let me know what might be the problem.

Regards,
-Rams


RE: Printing Ascii text by coreyb

coreyb
Tue Aug 02 21:15:05 CDT 2005

I found a list of the control codes here:
http://www.robelle.com/library/smugbook/ascii.html

I'm not certain which one will tell the printer to finish the job.