Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing a binary file

Status
Not open for further replies.

Gafling

Programmer
Nov 7, 2000
44
US
I have a binary file (text with embedded HP PCL) that I want sent to an operator selected printer. This file is created by an old 'c' program that writes directly to 'PRN' to avoid any OS added data. Here is the old code:
...
...
PrintFile = fopen(PrintFileName, "rb");
while ((ch=fgetc(DataFile)) != EOF)
{
fputc(stdprn,ch);
}
fclose(PrintFile);
...
...

When moving this code to BCB5, I added code to allow the operator to select the printer on which to print the file. Here is the new code:
...
...
if (!PrintDialog1->Execute())
return(-1);

Printer()->BeginDoc();
// WHAT GOES HERE???
Printer()->EndDoc();
...
...

I understand Execute, BeginDoc, EndDoc, etc but I am unsure of how to transfer the binary file data to the spooler. Is there a method in TPrinter that does that? Or do I need to redirect 'cout' to the printer handle? Do I need to process the binary file in a loop as in the old program? or
what else ...

Thanks!
 
do you have problems with binary file format or with data transfering? John Fill
1c.bmp


ivfmd@mail.md
 
John, Thank you for responding. The problem I have is how to get the binary file to the printer, but let me see if I understand your question.

The binary file is correct. It contains the PCL necessary to format the page in the format required by this application. I have used the 'c' version of this program under DOS for years. Of course on a DOS machine there is usually only one printer; writing to 'PRN' or 'stdprn' is acceptable and legal.

So assuming the file is correct, the question remaining is the type of procedure needed to get the binary file data out to an operator selected printer. The 'Execute' function will allow the operator to select the PCL style printer they want. After that I am unsure of how to proceed. I am examining at least three types of coding involving which are mentioned in the original post.

I would appreciate any input.

Thanks.
Gafling
 
I think you should get the DC of the printer and write in it. See GDI and WinAPI. Some more questions can be borland specific. John Fill
1c.bmp


ivfmd@mail.md
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top